|
|
View previous topic :: View next topic |
Author |
Message |
lubom
Joined: 20 Apr 2006 Posts: 6
|
18f2580 with EUSART...can't wake up from sleep |
Posted: Wed Jul 12, 2006 5:50 am |
|
|
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
Im using interrupts on ext2, and lp operating timer1 if this have any matter.
Best regards and thanks in advance!!!
Lubomir |
|
|
Ttelmah Guest
|
|
Posted: Wed Jul 12, 2006 6:51 am |
|
|
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
|
|
Posted: Tue Nov 21, 2006 6:47 pm |
|
|
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. |
|
|
|
|
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
|