lpcware

LPC11C24  about   uart

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by wzq121381 on Tue Nov 05 07:46:08 MST 2013
This  is  my  code,I  want  to  send   01 05 00 02 FF 00 2D FA  then  the  led  is  lighten,and  then  01 05 00 02 00 00 6C 0A,the 
led  is  dark.  after   i  download  the  code  ,the  result  is  not  the  same  as  i  hope .can  you  help me?

#include "driver_config.h"

#include "target_config.h"
#include "gpio.h"

#include "uart.h"

extern volatile uint32_t UARTCount;
extern volatile uint8_t UARTBuffer[BUFSIZE];

int main (void)
{

  UARTInit(9600);
SystemInit();

GPIOSetDir(2,10,1);

  while (1)
  {/* Loop forever */
if ( (UARTBuffer[0]==0x01)&&(UARTBuffer[1]==0x05)&&(UARTBuffer[2]==0x00)&&(UARTBuffer[3]==0x02)&&(UARTBuffer[4]==0xff)&&(UARTBuffer[5]==0x00)&&(UARTBuffer[6]==0x2d)&&(UARTBuffer[7]==0xfa) )
{
LPC_UART->IER = IER_THRE | IER_RLS;/* Disable RBR */
UARTSend( (uint8_t *)UARTBuffer, UARTCount );
GPIOSetValue(2,10,1);

UARTCount = 0;
  LPC_UART->IER = IER_THRE | IER_RLS | IER_RBR;/* Re-enable RBR */
}
else if ( (UARTBuffer[0]==0x01)&&(UARTBuffer[1]==0x05)&&(UARTBuffer[2]==0x00)&&(UARTBuffer[3]==0x02)&&(UARTBuffer[4]==0x00)&&(UARTBuffer[5]==0x00)&&(UARTBuffer[6]==0x6c)&&(UARTBuffer[7]==0x0a) )
{
  LPC_UART->IER = IER_THRE | IER_RLS;/* Disable RBR */
UARTSend( (uint8_t *)UARTBuffer, UARTCount );
  GPIOSetValue(2,10,0);

UARTCount = 0;
LPC_UART->IER = IER_THRE | IER_RLS | IER_RBR;/* Re-enable RBR */
}

  }

}

Original Attachment has been moved to: uart.zip

Outcomes