AnsweredAssumed Answered

TWR-VF65GS10 uart1 read operation failing in MQX

Question asked by manjug on Oct 17, 2014
Latest reply on Feb 10, 2015 by Vilem Zavodny

Hi,

I have attached the document with register values before UART initialized and after initialized.

Jumper settings

J23: 1-2 and 3-4 connected(SCI1_TX to UART1_ELEV_TX and SCI2_TX to OpenSDA_RX)

J24:1-2 and 3-4 connected(SCI1_RX to UART1_ELEV_RX and SCI2_RX to OpenSDA_TX)

 

Read is not happening on "ttyb:".UART1 RX pin is continuously fed with strings at 4800 baudrate , Parity:None, Stop bit:1 and No flow control.

below is the code:

 

#define NMEA_MAX_SIZE 256

#define NMEA_PORT_CHANNEL "ttyb:"

 

UART_task(){

bool disable_rx = FALSE;

   int32_t baud = 4800;

   int32_t result;

   int32_t ser_opts = IO_SERIAL_NON_BLOCKING;

   int32_t stop_bits=IO_SERIAL_STOP_BITS_1;

   int32_t data_bits=8;

   int32_t parity=IO_SERIAL_PARITY_NONE;


   nmea_port_dev = fopen(NMEA_PORT_CHANNEL,NULL);


   if(nmea_port_dev!=NULL){

   printf("dev pointer value:%d",nmea_port_dev);

   }


   ioctl(nmea_port_dev, IO_IOCTL_SERIAL_SET_FLAGS, &ser_opts);

   ioctl(nmea_port_dev, IO_IOCTL_SERIAL_DISABLE_RX, &disable_rx );

   ioctl(nmea_port_dev, IO_IOCTL_SERIAL_SET_BAUD, &baud);

   ioctl(nmea_port_dev, IO_IOCTL_SERIAL_SET_DATA_BITS,&data_bits);

   ioctl(nmea_port_dev, IO_IOCTL_SERIAL_SET_STOP_BITS,&stop_bits);

   ioctl(nmea_port_dev, IO_IOCTL_SERIAL_SET_PARITY,&parity);

 

  while(1)

  {

  memset(NMEA_text, 0,  NMEA_size);

 

  result=fread(NMEA_text,1,5, nmea_port_dev);//Trying to read length of 5

 

  if(result>0){

  NMEA_text[result+1]='\0';

  write( nmea_port_dev, NMEA_text, strlen(NMEA_text) );

  fflush(nmea_port_dev);

  ioctl(nmea_port_dev, IO_IOCTL_SERIAL_WAIT_FOR_TC,NULL);

  memset(NMEA_text, 0,  NMEA_size);

  }

  else{

  write( nmea_port_dev, data_buffer, strlen(data_buffer) );

  }

}

}

Outcomes