UART - mqx write not accessing the UART registers

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

UART - mqx write not accessing the UART registers

1,574 Views
Cdn_aye
Senior Contributor I

Hi

I have a logic analyzer on TX0 capturing the output of uart0, but I under mqx 3.8.1 I don't see any output.

I get a 0 for the return status on all the mqx calls which I think is a success. The file open works, the baud rate is set and read back ok, same with the status on the write. But nothing is coming out the Tx line. When I step into the mqx _io_write, all I can see happening is the length of the buffer is being calculated, it never access's any uart registers, it is almost as if the mqx uart code is not being compiled but I can't see where any conditional exclusion occurs, yet the RTOS returns a 0 on the write call.

Any help would be appreciated.

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I have this in the user_config.h, I am assuming that ttya: is channel 0 of the uart., the bsp and psp were recompiled without error.

#define BSP_DEFAULT_IO_CHANNEL              "ttya:"

#define BSP_DEFAULT_IO_CHANNEL_DEFINED

/* MGCT: <generated_code> */

#define BSPCFG_ENABLE_TTYA       1

void rs232_write (void)

{

static MQX_FILE_PTR        p_fd_rs232 = NULL;

static char                ac_data_buffer[10] = "AT\n", *pac_data_buffer;           // "AT&F*";

static sint32              s32_result;

static uint32              u32_result;

static uint32              u32_param, u32_char_rcvd = 0;

static bool                temp;

    pac_data_buffer = ac_data_buffer;

    fflush(stdout);

    p_fd_rs232  = fopen( SERIAL__CHANNEL, NULL );        // HW, will not use flow cntrl

// **rwl        p_fd_rs232  = fopen( SERIAL__CHANNEL, BSP_DEFAULT_IO_OPEN_MODE );        // HW, will not use flow cntrl

    if( p_fd_rs232 == NULL ){

        vFn_Printff();        //"error");

    }

    fflush(stdout);

    u32_param = 9600;

    s32_result = ioctl( p_fd_rs232, IO_IOCTL_SERIAL_SET_BAUD, &u32_param );// set, wait for transfer complete flag

    s32_result = ioctl( p_fd_rs232, IO_IOCTL_SERIAL_GET_BAUD, &u32_param );

    fflush(stdout);

    while(1){

// **rwl            s32_result = write( p_fd_rs232, ac_data_buffer, (long)strlen(ac_data_buffer) );           // write data

        s32_result = _io_write( p_fd_rs232, ac_data_buffer, (long)strlen(ac_data_buffer) );           // write data

        _time_delay(1);

    }

0 Kudos
5 Replies

450 Views
c0170
Senior Contributor III

Hello Robert Lewis,

To start the discussion, are UART registers set properly ? What's the value of SERIAL__CHANNEL ?

Set breakpoint in _io_write in the end (return statement).  This call should jump to the _io_serial_polled_write() function located in /io/serial/polled/serl_pol.c . Is that it? What are the parameters there, do they designate values of your _io_write call parameters? From there, depending of your serial flags, polled_dev_ptr->DEV_PUTC is invoked.

Regards,

MartinK

0 Kudos

450 Views
Cdn_aye
Senior Contributor I

Hi Kojito

I have

#define SERIAL__CHANNEL                     "ttya:"             // set SERIAL_ output device, sci0

I can't set a breakpoint in _io_write, when I step into _io_write, the only code I see is the string length calculation, then it returns. This is my main problem. I have rebuilt the bsp, psp and rebuilt the project; same thing. I am assuming that ttya is translated somewhere to uart0. But I can't see where that happens.

Thanks for the reply

Robert

0 Kudos

450 Views
c0170
Senior Contributor III

Hello,

ttya is "translated" in init_bsp.c. This preprocceses

_kuart_polled_install("ttya:", &_bsp_sci0_init, _bsp_sci0_init.QUEUE_SIZE). Debug this initialization if possible to find out if uart is initialized in the beginning.

If io_write gives you issues to debug, place breakpoint in putc function inside polled serial driver (serl_pol_kuart).

Did you enable optimizations? If you plan to debug, libs and application should have optimizations off.

Regards,

MartinK

0 Kudos

450 Views
Cdn_aye
Senior Contributor I

Hi Kojto

I was suddenly pulled off of the uart problem to work on something else. I am back and will let you know what I find. Thank you for responding.

0 Kudos

450 Views
Cdn_aye
Senior Contributor I

Hi

I went to the example rs485 under the mqx examples. Rebuilt the bsp to use ittya, Did

#define RS485_CHANNEL "ittya:"

rebuilt the bsp then the app. I see the device file block pointer assigned so I know the bsp is ok on that level. But there is nothing coming out on the pin. I think the problem is that the pin is not assigned correctly. We are using PTA14 as UART0_TX, which is ALT3. But I did not tell MQX anywhere that that was what I was using. How to I create the assignment? I know how to do this manually outside of MQX in an init function, but not within MQX.

I think this is the problem. Can anyone tell me how to set up the assignment please?

Thank you'

Robert

0 Kudos