I have a hardware with RN-41 bluetooth module and the lpc 214 arm microprocessor.Currently my device only sends data to the PC and I am trying to configure it to be able to receive some commands over bluetooth and perform certain actions e.g. blink LED,Shutdown etc.
I have a serial GUI in matlab which has buttons on it (LED ON,LED OFF,SHUTDOWN etc)where each button on being pressed sends a value associated with it to the hardware over a virtual serial port to perform a certain action.
Till now I have not been able to get my device to perform any action correctly.I definitely see the hardware responding to a button press in strange ways but never performs the desired action.I feel I may have configured the UART incorrectly. I am pasting some code associated with this issue here.
Any help would be greatly appreciated.
Thanks!
void setup_uart0(int newbaud, char want_ints)
{
baud = newbaud;
U0LCR = 0x83; // 8 bits, no parity, 1 stop bit, DLAB = 1
U0DLM = 0x00; // set for baud high byte
U0DLL = 0x06; // set for baud low byte
U0FDR = 0xC1;
U0LCR = 0x03;
VICVectCntl1 = 0x00000026;
VICVectAddr1 = (unsigned int) UART0ISR;
VICIntEnable = (1<<6);
//PINSEL0 = 0x0F001555;
}
void UART0ISR(void)
{
unsigned int i;
unsigned char ch;
U0IER = 0x01;
while(!(U0LSR&0x01));
uart0_rx_buffer[uart0_rx_extract_idx++]=U0RBR;
uart0_rx_extract_idx %=UART0_RX_BUFFER_SIZE;
ch = uart0_rx_buffer;
for (i=0;i<8;i++)
uart0_rx_buffer[i]= 0;
return U0RBR;
if(ch ==0x0A){
VICIntEnable &= (~0x00020000);
eventMarker=1;
ch=0;
}
else if (ch ==0x0B){
shutdown();
ch=0;
}
else if (ch ==0x0C){
blink(1,ON);
ch=0;
}
else if (ch ==0x0D){
blink(1,OFF);
ch=0;
}
VICIntEnable |= 0x00024000;
VICVectAddr= 0;
U0IER = 0x00;
}