1 Reply Latest reply on Jul 29, 2015 2:38 AM by maheshb_81

    Deep Sleep Wakeup from UART

      Hi all,


      I'm new to forums so excuse me if I don't follow protocol, but please don't hesitate to correct me. I have searched for an answer to this for quite a bit of time, but to no avail. I will try to be as detailed as possible.


      I am trying to use my CYBLE-022001-EVAL board on a CY8CKIT-042-BLE Pioneer Baseboard, to establish a BLE connection between my microcontroller and a smartphone. I have not progressed to using a microcontroller or a smartphone yet, but I have successfully interfaced between my Cypress BLE dongle (acting as the smartphone; using CySmart on my PC), and a terminal program on my computer (acting as the microcontroller).


      I have successfully updated the GATT database over my "UART" connection (which is my terminal program), and I am able to send notifications and indications, given certain commands. I am also able to write values to the GATT database from the BLE dongle, and my firmware is set up to write these values to UART upon reception.


      All of this code works great when I do not attempt to use Deep Sleep. I read in a Cypress Component Datasheet for the Serial Communication Block that:


           "The component in UART mode is able to be a wakeup source from Sleep and Deep Sleep low power modes."


      In addition, it says the following:


           "The "Enable wakeup from Deep Sleep Mode" must be checked in the UART configuration dialog and RX direction enabled. The SCB_Sleep() and SCB_Wakeup() functions must be called before/after entering/exiting Deep Sleep. The device wakes up by the RX GPIO falling edge event that is generated by the incoming start bit."


      There are two constraints for the wakeup:


           1) "The 1st data bit of wakeup transfer has to be ‘1’. The UART skips the start bit and synchronizes on the 1st data bit."


       2) "The wakeup time of the device must be less than one bit duration; otherwise, the received data will be incorrect."


      The last requirement is the following:


           "The UART transmitter must complete the ongoing transfer before entering Deep Sleep"


      (according to the datasheet, this is accomplished using the following code)


           while (0u != (SCB_SpiUartGetTxBufferSize() + SCB_GET_TX_FIFO_SR_VALID));


      Finally, there is a note in the datasheet:


           "RX GPIO interrupt restricts usage of all GPIO interrupts from the port where the UART rx pin is placed."




      As far as I can tell, I am doing things correctly:


           -I checked the "Enable wakeup..." box


           -My wakeup data is 0b10000001 (because I don't know if the LSB or MSB is transferred first)


           -I use the "wait for transmit complete" code above


           -And finally, I have called the UART_1_Sleep() and UART_1_Wakeup() functions (the names are generated differently because of the name of my UART block)




      However, when I compile and program this code, the UART no longer receives. It transmits, but it will not receive. Using debugging, I have found out that the receiver buffer never gets any data. When I call the following function, it returns zero every time:






      My theory is that I need to activate the RX GPIO interrupt, or perhaps write an ISR, but the documentation does not say anything about that. Could anyone help me? Even just example code that works would be helpful. The following information is as much as I can think to include:


           -I am using PSoc Creator 3.2


           -My BLE module is version 2.0


           -My UART module is version 3.0


           -The terminal program I am using is Docklight V2.0, trial version


           -My CySmart software is version 1.1


           -The information about the UART wakeup from deep sleep is in the UART module datasheet, on page 163, under "Low power modes"




      I know that it is standard practice to upload code, but my project is proprietary, and I am not able to. My apologies.