AnsweredAssumed Answered

I am interfacing a peripheral to UART0. When I try to write data to it for the first time it is not writing to the peripheral.

Question asked by chandra sekhar on Nov 21, 2013
Latest reply on Dec 5, 2013 by chandra sekhar

I am using TWR-K21F120M board. Using MQX4.0.

I am interfacing a finger print scanner to UART0. I am unable to write data to it for the first time. But it takes data for the second time.

 

unsigned char buffer[] = {0x02, 0x61, 0x02, 0x21, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x01, 0xDD, 0x69, 0x1B, 0x03};

  unsigned char buffer1[100] = {0x00};

  uint_8 count;

  uint_32 Baudrate=9600;

 

UARTA = fopen("ttya:",(char const*)(IO_SERIAL_RAW_IO|IO_SERIAL_TRANSLATION)); //opening the device

if(NULL==UARTA)

  {

 

  _task_block();

  }

  if( MQX_OK !=_io_ioctl(UARTA,IO_IOCTL_SERIAL_SET_BAUD,&Baudrate)) //UART0 settings

  {

  _task_block();

  }

 

 

while(TRUE)

  {

 

        count = write(UARTA,buffer,sizeof(buffer)); //Writing data to UARTA,Even though the return value is positive, the data is not going to the peripheral connected to the UART0

 

          for(i = 0; i < 4; i++)

            {

                 read(UARTA,buffer1,4); //

            }

       for(i = 0; i < 4; i++)

       printf(" the buffer is %02X", buffer1[i]);

 

}

 

Can anybody explain why this is happening.?

Outcomes