Hi--
I am working on a custom CC2640 4x4 application using BLE stack 2.2, TI RTOS 2.18,
CCS 6.1.2.
The application uses the SPI driver with 2 slaves and the UART driver in read callback
mode. When the sensor is powered on, it waits for UART activity for a few seconds monitored
by Clock_getTicks(). If there is no UART activity, the UART is closed and sensor resumes
normal operation.
In checking the standby current draw, if the UART monitoring is never done, the current
draw is 1 uA. So the custom board is capable of 1uA current draw with a functioning
SPI driver.
With the UART monitoring code in place, the standby current draw is in the order of 1.5 mA.
All GPIOs have been defaulted as outputs with the states low (except for the SPI chip
selects). There is nothing driving the UART. The UART is closing after a period of
inactivity but the standby current draw does not drop down.
The UART callback function assembles the UART message frame one byte at a time,
checking for invalid messages and the length of incoming message frames. At the end of
the assembled message, the message processing happens through the RTOS queue.
The callback function has been checked several times and has been written with no
redundancy or repetition. Is there any feature of the UART driver that can be of help
here? Is there any other way to set up the UART?
Thanks,
Priya
static void SimpleBLEPeripheral_taskFxn(UArg a0, UArg a1)
{
// Initialize application
SimpleBLEPeripheral_init();
waitForUARTMessage();
// Application main loop
for (;;)
static void waitForUARTMessage(void)
{
uint8_t byte;
if (waitForNormalMode)
UART_read(uart, &byte, 1);
if (talkMode){
if (!processingUARTMsg) {
UART_read(uart, &byte, 1);
}
}
}
static void UARTCallback(UART_Handle uart, void *byte, size_t size)
{
static uint8_t value, i, length = 5;
value = *((int*)byte);
#if defined (Debug)
System_printf("\nvalue= %x\t", value);
#endif
uart_rx_buf[i] = value;
i++;
// if the very first byte is a x55, set the talk mode flag and send a 1 byte
// go into talk mode confirmation through UART
// processingUARTMsg gets set just before entering the message into the RTOS queue.
if (i == 1 && value != 0x01) {
if (value == 0x55) {
talkMode = 1;
i = 0;
length = 5;
processingUARTMsg = 1;
UART_enqueueMsg(1);
}
// if the first byte is not go into talk mode or SOH, re-set i and set message length to 5.
// what happens when length is 5?
else if (value != 0x01) {
i = 0;
length = 5;
}
}
// Check for valid operation.
// if message byte is not valid, re-set i and fix length at 5.
else if (i == 2 && (value < 0x80 || value > 0x8f)) {
i = 0;
length = 5;
}
// if byte number 5 is 0, there are no following message bytes, send the message to the RTOS queue.
else if (i == 5) {
if (value == 0x00) {
i = 0;
length = 5;
processingUARTMsg = 1;
UART_enqueueMsg(5);
}
// determine correct message length for write into SNV
// however read eeprom message format is different and value of length is in byte 6, not byte 5.
else {
length = value + 5;
}
}
else if (i >= length) {
i = 0;
length = 5;
processingUARTMsg = 1;
UART_enqueueMsg(length);
}
waitForUARTMessage();
}