CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

18f2580 with EUSART...can't wake up from sleep

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
lubom



Joined: 20 Apr 2006
Posts: 6

View user's profile Send private message

18f2580 with EUSART...can't wake up from sleep
PostPosted: Wed Jul 12, 2006 5:50 am     Reply with quote

Hi iam am trying to make 18f2580 to wake up from sleep every i send a character over pc serial port here is the part of code:

Code:

#include <18F2580>
#use delay(clock=8000000)
#use rs232 (baud=19200,parity=N,bits=8,xmit=PIN_c6, rcv=PIN_c7, errors)
#FUSES NOWDT,  LPT1OSC, PUT,NOBROWNOUT,NOPBADEN,NOSTVREN,NODEBUG,NOLVP,NOIESO,NOPBADEN
#use rs232 (baud=19200,parity=N,bits=8,xmit=PIN_c6, rcv=PIN_c7, errors)
...
main()
enable_interrupts(INT_RDA);
enable_interrupts(GLOBAL);
SETUP_UART(UART_WAKEUP_ON_RDA);
     while(1){
     SLEEP();
     clear_interrupt(INT_RDA);
     }
}

#int_RDA
RDA_isr()
{ GETC(); }
}


May be im doing something wrong so please help me Smile
Im using interrupts on ext2, and lp operating timer1 if this have any matter.
Best regards and thanks in advance!!!
Lubomir
Ttelmah
Guest







PostPosted: Wed Jul 12, 2006 6:51 am     Reply with quote

There are limitations to this ability. The clock needs to wake fast enough for the character to be received, when the falling edge of the start bit is detected. There are therfore severe limitations on doing this with some oscillator sources. You might be better off putting the chip into 'PRI_IDLE' mode, rather than fully asleep, which will leave just the oscillator running.
Why are you clearing the interrupt in the main loop?. When you 'sleep', the next instruction is 'prefetched, and normally this is executed before the interrupt is actually serviced. I wonder what the effect of having an interupt 'clear' prefetched will be? The interrupt will be cleared in the handler, so I'd personally just put a 'nop' after the sleep (delay_cycles(1)).

Best Wishes
Assen



Joined: 18 Oct 2006
Posts: 8

View user's profile Send private message

PostPosted: Tue Nov 21, 2006 6:47 pm     Reply with quote

I think the problem here is that the main loop is going so fast that there is no time to receive a char. When the micro wake up from the strarting edge then new cycle in the main loop go back to sleep and that stops the oscillator and the micro is not able to receive the char. You have to put delay of at least 1 char time before going back to sleep.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group