Wake-up PIC with USART RX

1.1k views Asked by At



I'm working with eXtreme Low Power (XLP) Microcontroller PIC 16LF1933.
For it to consume little battery, I put it to sleep until it receives a Break character (00h) in RX. The documentation explains well how to set the Auto-Wake-up with Break character in RX. I followed it.

I'm using Proteus to simulate the project, with Virtual Terminal to send information. If you press
CTRL + SHIFT + @ it sends de 00h (null/ all 0's), so, this would wake up the PIC, as said in documentation.
The problem is, when I do this, I receive a warning log saying that
Wake up event is only 937.500003us wide. Minimum (at current baudrate) expected is 6.656ms. I'm using 9600 baudrate.
How do I make a proper Wake up event with RX?

My while code

while (1) {
    BAUDCONbits.WUE = 1;    //Wake-up Enable
    SLEEP();

    while (BAUDCONbits.WUE);

    msg = Receive_Serial(); //Clear RCIF
    __delay_ms(100);
    msg = '\0';             //Discard
    __delay_ms(100);
    msg = Receive_Serial(); //Receive the next character
    __delay_ms(100);
    RCREG = 0;
    msg = '\0';
    __delay_ms(100);
}


And my Receive function

unsigned char Receive_Serial() {
    if (OERR) {                 //Overrun error
        RCSTAbits.CREN = 0;     //Fix reset Enable Receive
        RCSTAbits.CREN = 1;
    }

    while (!RCIF);

    return RCREG;
}



1

There are 1 answers

0
Peter Camilleri On

The warning message you get is simply due to the fact that a null character (00h) is NOT a break condition.

Your pic code may be fine but the dev tool is not generating the correct test data.

Long long ago, I was once desperate to send a break to wake up a piece of dormant equipment and needed to send it a break. My terminal could not send one. I had to get this working so a quick hack was to send a null character with the terminal set to a lower baud rate, and switch back to the correct baud rate.