chipKIT® Development Platform

Inspired by Arduino™

Problems with cli & sei

Created Sun, 18 Aug 2013 03:22:50 +0000 by joncollins


Sun, 18 Aug 2013 03:22:50 +0000

I am compiling this software from Adafruit:

I posted the error received on ther forum and received the response below:

Compiling DHTtester on MPIDE 23 gives me errors:

In member function 'Boolean DHT::read() 'cli' was not defined 'sei' was not defined

Any suggestions. I was under the impression that this board and software was fully compatible. jonathanco

Posts: 1 Joined: Thu May 30, 2013 6:30 pm Top Re: AM2302 DHT on Chipkit Ardunio UNO by adafruit_support_rick » Sat Aug 03, 2013 9:08 am

cli and sei are AVR-family machine instructions to globally enable and disable interrupts.

The Adafruit AM2302 library uses macro implementations of these two instructions, cli() and sei(). The macros are defined in avr/interrupts.h.

The MPIDE system should have re-defined these macros to produce the appropriate PIC instructions. This appears to be a bug in MPIDE. You should follow up with the developers to get this resolved.



Sun, 18 Aug 2013 15:43:51 +0000

The problem here is that sei() and cli() are fine on a simple chip like the AVR with limited interrupt facilities.

On the PIC32 though the interrupts are considerably more complex. You can't just turn them off and turn them on again - you have to record what they were, and then restore them afterwards.

unsigned int oldInterrupts = disableInterrupts();
//.. your code