TWR-VF65GS10:UART1 receive pin -not able to read data into buffer

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

TWR-VF65GS10:UART1 receive pin -not able to read data into buffer

1,498 Views
manjug
Contributor III

Hi ,

I have connected UART1 RX pin of TWR-VF65GS10 to my App-Board UART TX pin and UART1 TX pin of TWR-VF65GS10 to RX pin to TTL converter board to PC.

I'm able to write data on UART1 TX pin of TWR-VF65GS10.

But I'm not able to read data on UART1 RX pin of TWR-VF65GS10.

Below is the UART1  settings i did and code chunk explaining my read operation.

In vybrid_TWRVF65GS10_a5.h

#ifndef BSPCFG_ENABLE_TTYB

    #define BSPCFG_ENABLE_TTYB              1

#endif

/*

** Interrupt-driven TTY device (UART1)

** MGCT: <option type="bool"/>

*/

#ifndef BSPCFG_ENABLE_ITTYB

    #define BSPCFG_ENABLE_ITTYB             0

#endif

/*

** TTYB and ITTYB baud rate

** MGCT: <option type="number" min="0" max="115200"/>

*/

#ifndef BSPCFG_SCI1_BAUD_RATE

    #define BSPCFG_SCI1_BAUD_RATE             4800

#endif

/*

** TTYB and ITTYB buffer size

** MGCT: <option type="number" min="0" max="256"/>

*/

#ifndef BSPCFG_SCI1_QUEUE_SIZE

    #define BSPCFG_SCI1_QUEUE_SIZE             256

#endif

#if BSPCFG_ENABLE_TTYC

  #define BSP_DEFAULT_IO_CHANNEL                        "ttyb:"

  #define BSP_DEFAULT_IO_CHANNEL_DEFINED

  #else

  #define BSP_DEFAULT_IO_CHANNEL                        NULL

  #endif

#ifndef BSP_DEFAULT_IO_OPEN_MODE

    #define BSP_DEFAULT_IO_OPEN_MODE                      (void *) (/*IO_SERIAL_XON_XOFF |*/ IO_SERIAL_TRANSLATION /*| IO_SERIAL_ECHO*/)

#endif

In my source file :

MQX_FILE_PTR port_dev = NULL;

  char text [256]={0};

  uint32_t len=sizeof(text);

bool disable_rx = FALSE;

   int32_t baud = 4800;

   int32_t result;

   int32_t ser_opts = IO_SERIAL_NON_BLOCKING;

   port_dev = fopen(NMEA_PORT_CHANNEL, BSP_DEFAULT_IO_OPEN_MODE);

   result = ioctl(port_dev, IO_IOCTL_SERIAL_SET_FLAGS, &ser_opts);

   result = ioctl(port_dev, IO_IOCTL_SERIAL_DISABLE_RX, &disable_rx );

   result = ioctl(port_dev, IO_IOCTL_SERIAL_SET_BAUD, &baud);

while(1)

  {

     memset(text, 0,  len);

       result=fread(text,1,18, port_dev);

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

       printf("String received :%s\n",text);

  }

13 Replies

965 Views
naoumgitnik
Senior Contributor V

Hello Manju,

Have you tried to check if the Tower board software package has a UART driver? - Referred to on the Freescale Tower board description web page.

If not, perhaps timesyssupport might help you with that.

Regards, Naoum Gitnik.

0 Kudos

965 Views
manjug
Contributor III

Dear Naoum Gitnik,

My post was with respect to MQX-RTOS.So,please help me in this regard.

0 Kudos

965 Views
alejandrolozan1
NXP Employee
NXP Employee

Hi,

I have not debugged the problem but I recommend you to check the iomux configurations after this function :

_mqx_int _bsp_serial_io_init

(

    /* [IN] Serial device number */

    _mqx_uint dev_num,

    /* [IN] Required functionality */

    _mqx_uint flags

)

{

    switch (dev_num) {

    case 0:

        IOMUXC_RGPIO(32) = 0x001011A2;

        IOMUXC_RGPIO(33) = 0x001011A1;

        break;

    case 1:

        IOMUXC_SCI_FLX1_IPP_IND_SCI_RX_SELECT_INPUT = 0x00000000;

        IOMUXC_SCI_FLX1_IPP_IND_SCI_TX_SELECT_INPUT = 0x00000000;

        IOMUXC_RGPIO(26) = 0x002011A2;

        IOMUXC_RGPIO(27) = 0x002011A1;

        break;

    case 2: // SCI2

        IOMUXC_SCI_FLX2_IPP_IND_SCI_RX_SELECT_INPUT = 0x00000000;

        IOMUXC_SCI_FLX2_IPP_IND_SCI_TX_SELECT_INPUT = 0x00000000;

        IOMUXC_RGPIO(28) = 0x007021A2;

        IOMUXC_RGPIO(29) = 0x007021A1;

    }

    return MQX_OK;

}

Just to make sure the pin configuation does not change in a certain moment due other driver.

Please check that and let us know.

Best Regards,

Alejandro

965 Views
manjug
Contributor III

Hi,

it is hitting

case 1:

        IOMUXC_SCI_FLX1_IPP_IND_SCI_RX_SELECT_INPUT = 0x00000000;

        IOMUXC_SCI_FLX1_IPP_IND_SCI_TX_SELECT_INPUT = 0x00000000;

        IOMUXC_RGPIO(26) = 0x002011A2;

        IOMUXC_RGPIO(27) = 0x002011A1;

        break;

and returns MQX_OK.

0 Kudos

965 Views
alejandrolozan1
NXP Employee
NXP Employee

Hi,

After that please make sure that the register configuration does not change.

Also please check the jumper settings in J24 and J23.

Best Regards,

Alejandro

0 Kudos

965 Views
manjug
Contributor III

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 still 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) );

  }

}

}

0 Kudos

965 Views
alejandrolozan1
NXP Employee
NXP Employee

Hi,

I just tested a simple hello world example with a scanf an getchar functions and it works correctly in TWR revG.

I noticed this in your configuration:

#if BSPCFG_ENABLE_TTYC

  #define BSP_DEFAULT_IO_CHANNEL                        "ttyb:"  


You have to make sure that BSPCFG_ENABLE_TTYC is 1 or just change it to BSPCFG_ENABLE_TTYB.

I lack of a H revision.

965 Views
manjug
Contributor III

Dear Alejandro Lozano,

I have already set BSPCFG_ENABLE_TTYC to 1. Now i used ttyc:(SCI2) (#if BSPCFG_ENABLE_TTYB  #define BSP_DEFAULT_IO_CHANNEL "ttyb:")

for opening the device and again reading is not happening.So,i used ttya:(SCI0) which i'm able to read an write with code i posted,Tap points on board for SCI0 are TP12(TX) and TP14(RX).Why ttyc: is not able to open eventhough i didn't set it for default i/o channel,i'm not able to read and write by using standard fread and fwrite?.

0 Kudos

965 Views
alejandrolozan1
NXP Employee
NXP Employee

Hi,

As I see it, the only difference is that I tried with scanf or getchar functions instead of fread.

Can you try with those functions? Also instead of re-opening the channel

  nmea_port_dev = fopen(NMEA_PORT_CHANNEL,NULL);


You can try just to copy the stdout :

nmea_port_dev = stdin;


fread(NMEA_text,1,5, nmea_port_dev);


Please try that and let me know how it goes.


Best Regards,

Alejandro

965 Views
karina_valencia
NXP Apps Support
NXP Apps Support

alejandrolozano do you have an update?

0 Kudos

965 Views
naoumgitnik
Senior Contributor V

Alejandro, manjug,

Except for the DDR section (due to its improved layout), there should be no difference between the G and H revision of the Tower module from the Vybrid-software point of view.

Regards, Naoum Gitnik.

0 Kudos

965 Views
alejandrolozan1
NXP Employee
NXP Employee

Sorry for the delay, let me try to reproduce the problem.

Best Regards,

Alejandro

0 Kudos

965 Views
karina_valencia
NXP Apps Support
NXP Apps Support

alejandrolozano please continue with the follow up.

0 Kudos