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

Question about UART not working after sleep()

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



Joined: 03 Dec 2013
Posts: 215

View user's profile Send private message

Question about UART not working after sleep()
PostPosted: Sun Sep 30, 2018 6:44 pm     Reply with quote

18F67K22
Compiler: V5.081

Hardware UART is working just fine before doing sleep();

My Question: Are there any known issues with UART not working after sleep() ?

CPU is running but UART is not working after sleep().
Code:

#use rs232(baud=115200,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8,stream=BLE,ERRORS)

// Code is working fine communication with external device is consistent.
// At one point in the code I need to call sleep();

sleep();
delay_cycles(1); // I also tried 2 cycles (nop's)

// wake up from sleep by RTC alarm Interrupt.
// at this point the UART no longer works.



I understand the sample is very limited, the full code is under NDA so I can't post it here.

I have tried disabling the uart before calling sleep() with a call to
setup_uart(0,BLE);

and then after wakeup from sleep() doing setup_uart(115200,BLE); to enable the uart again. It did not fix the problem.
I have tried sleep(SLEEP_IDLE); and that did not fix the problem.

Any suggestions regarding how to enable the uart after sleep() is welcome.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Sep 30, 2018 7:23 pm     Reply with quote

What happens if you do a delay of 100 ms after waking up from sleep,
before using the UART ?
soonc



Joined: 03 Dec 2013
Posts: 215

View user's profile Send private message

Cried UNCLE too soon... !
PostPosted: Sun Sep 30, 2018 8:02 pm     Reply with quote

Buffer overrun caused the issue...!
UART works fine after sleep, and when not sowing weeds in the garbage patch!
temtronic



Joined: 01 Jul 2010
Posts: 9081
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Mon Oct 01, 2018 4:50 am     Reply with quote

You need to make sure first thing PIC does just before AND after it wakes up from sleep, is to purge (clean out) or read the receive buffer.
I can see how any device attached to the serial input could send data and fill the buffer. I've never used sleep() and serial together so I've never read the datasheet to see how Microchip handles that situation.
Jay
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