Sleep instruction executed when SE bit is not set. Do nothing.

Discussion on both general simulation and Proteus VSM microcontroller simulation.
Post Reply
picchiedi
Professional User
Posts: 142
Joined: Thu 2014-12-25 9:32

Sleep instruction executed when SE bit is not set. Do nothing.

Post by picchiedi »

Hello.
When I run the code below in Proteus ( IAR C) found in the web (complete code is folder "THN128 receiver" by A.Yerezeyev), between one timer1 interrupt service and the other I have the message as per subject: Sleep instruction executed when SE bit is not set. Do nothing.
Don't know what it exactly means.

I expected at the end of the main a while(1) endless expecting the interrupt to occur, but it's not the case.
In spite of this it seems there's a CPU sleep at the end of the main, after the printf of the string, that works and waits for timer1 interrupt every 16us.
I don't understand why there's a sleep instruction executed, since I can see no sleep call at all in the code.
Is the closing curly brace enough to tell the compiler to sleep waiting for the interrupt?

Thanks a lot for any kind clarification.

Regards

Code: Select all

/********************************************************************************************
 Oregon Scientific v 1.0 decoder routine for THN128 sensors and RLP434A 433.92MHz receiver
 (c) by Alexander Yerezeyev 2007-2009  
  URL: http://alyer.frihost.net
  email: wapbox@bk.ru
  ICQ:  305-206-239

  MCU: ATMEL AVR ATMEGA16 @ 16MHz
********************************************************************************************/

#include "main.h"
#include "io.h"

#define MainTimerStart()\
  TCCR1B=(1<<WGM12)|(1<<CS00);\
  OCR1A=0x00FF;\
  sbi(TIMSK,OCIE1A);

char const __flash _Hello_string[]=\
"\r\n***********************************\r\n\
*** Oregon Scientific THN128 receiver\r\n\
*** v1.00 ATmega16\r\n\
*** (c)2009 by Alexander Yerezeyev\r\n\
*** e-mail: wapbox@bk.ru\r\n\
*** http://alyer.frihost.net\r\n\
*** ICQ: 305206239 \r\n\
************************************ \r\n";

int main( void )
{
  sbr (DDRD, PD5); // LED pin as output
  _delay_ms(200);
  cbr (PORTD, PD5); // LED OFF    
  #ifdef TRACEMODE
    uart_init();  
  #endif  
  cli();
  MainTimerStart();
  sbr (TIMSK, OCIE0); //enable OC T0 interrupts  
  sbr (MCUCR, ISC11); // Falling edge on INT1 generate an interrupt  
  cbr (MCUCR, ISC10);
  sbr(GICR, INT1);    // Enable INT1 processing   
  GIFR=(1<<INTF1);  // Clear INT1 IRQ  
  sei();
  #ifdef TRACEMODE
    printf_P(_Hello_string);
  #endif  
}
Ettore
Labcenter Staff
Posts: 2931
Joined: Fri 2006-03-03 11:56
Location: Milan
Contact:

Re: Sleep instruction executed when SE bit is not set. Do nothing.

Post by Ettore »

SE is the sleep enable bit which is 0 by default. The warning message tells simply that a sleep instruction was encountered but SE bit was not enabled. Possibly an intrincic sleep instruction is added automatically at the end of the main() block by the IAR compiler for code safety reason, albeit I cannot verify it as I don't have such the IAR compiler. However to be honest I didn't find out any note about such the feature on the IAR documentation. Anyway, the 16-bit opcode sequence of the SLEEP instruction is 0x9588. You can investigate your self by looking at that opcode to see whether it is added by the compiler or not.
Kind regards,
Ettore Arena - Labcenter Electronics.
picchiedi
Professional User
Posts: 142
Joined: Thu 2014-12-25 9:32

Re: Sleep instruction executed when SE bit is not set. Do nothing.

Post by picchiedi »

Great Ettore.
Thanks a lot.
I performed the disassembly (see enclosed .jpg) through AVRStudio.
As far as I understand (hope not bad), there's a startup_call_main that calls the main function, and at
the return from main there's a new call to a no source and _exit sub.
Inside this _exit, there's the 0x9588 sleep.
I didn't image that the main is called by someone... :).
Thanks a lot for your kind clarification.
Regards
Attachments
Disassembler3.JPG
Disassembler3.JPG (207.68 KiB) Viewed 649 times
Disassembler2.JPG
Disassembler2.JPG (204.56 KiB) Viewed 649 times
Disassembler1.JPG
Disassembler1.JPG (199.48 KiB) Viewed 649 times
Post Reply