Hi,
I am trying to send data from msp430 to cc2540 keyfob via uart.
just for test, in msp430 i set baud rate as 115200 with no parity and 1 stop bit, and send a number increment from 1 every second.
and i have modified the code of function "SimpleBLEPeripheral_Init()" in the file simpleBLEPeripheral.c from the project "simpleBLEPeripheral".
the modified part is as shown below:
#if defined( CC2540_MINIDK )
.....
.....
#endif // #if defined( CC2540_MINIDK )
//
P0SEL = 0; // Configure Port 0 as GPIO
P1SEL = 0x30; // Configure Port 1 as GPIO, except P1.4 P1.5 for uart
P2SEL = 0; // Configure Port 2 as GPIO
P0DIR = 0xFC; // Port 0 pins P0.0 and P0.1 as input (buttons),
// all others (P0.2-P0.7) as output
P1DIR = 0xFF; // All port 1 pins (P1.0-P1.7) as output
P2DIR = 0x1F; // All port 1 pins (P2.0-P2.4) as output
P0 = 0x03; // All pins on port 0 to low except for P0.0 and P0.1 (buttons)
P1 = 0; // All pins on port 1 to low
P2 = 0; // All pins on port 2 to low
// the part above is in the "#if defined( CC2540_MINIDK )" part originally, i move it out and change some value to define P1.4 and P1.5 as uart ports
PERCFG |= 0x01; //usart0 alt.2
U0GCR = 0x0b;
U0BAUD = 216;
U0CSR = 0x80; //uart mode
U0UCR = 0x02; //low start bit, high end bit
U0CSR |= 0x40;
....
....
and i also modified the function "performPeriodicTask()" as shown below.
static void performPeriodicTask( void )
{
uint16 i;
i = U0DBUF; // only LSB 8 bits used
SimpleProfile_SetParameter( SIMPLEPROFILE_CHAR4, sizeof(uint16), &i);
}
}
i have modified this function to perform the notification with 2 bytes every time as show above, and this works properly since i have tried to send a number increment from 1 every second derectly from the cc2540 keyfob to Btool.
Since I have modified the period of the function as 1000ms, which is just same with the period msp sending datas via uart; thus i did not use at interupt or anything else, but just read the buffer during each period task.
However, whatever i send from msp430, the data Btool receives is always 0 at first for tens seconds, and then may change to 3, and at last becomes 0xFF later.