MQX 3.8 Disable UART

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

MQX 3.8 Disable UART

Jump to solution
2,882 Views
AA7
Contributor I

Hi,

With MQX 3.8.

We are using the macro BSPCFG_ENABLE_TTYA and the API function _mcf54xx_uart_serial_polled_install to configure the UART and use it as the default interface for the Shell and the standard IO functions. This works just fine. Now we want to enable/disable the uart at runtime. We have tried disabling the UART,

- writing directly to the peripheral registers,

- using _io_set_handle(IO_PROC_STDOUT(or IN), gs_NullDrv) (as suggested in the forum)

- or with _io_fclose().

Either MQX crashes or the UART does not get disabled. What would be the right way to disable and re-enable the UART?

Tags (1)
0 Kudos
Reply
1 Solution
2,850 Views
danielchen
NXP TechSupport
NXP TechSupport

Sorry I only have MQX 4.2 installed on my PC.

Please refer to the implement in MQX 4.2

 

serial.h

 

#define IO_IOCTL_SERIAL_DISABLE_RX _IO(IO_TYPE_SERIAL,0x17)
#define IO_IOCTL_SERIAL_WAIT_FOR_TC _IO(IO_TYPE_SERIAL,0x18)

 

sel_pol_kuart.c


case IO_IOCTL_SERIAL_DISABLE_RX:
if( *(bool *)param_ptr == TRUE )
{
/* disable receiver */
sci_ptr->C2 &=~UART_C2_RE_MASK;
}
else
{
/* enable receiver */
sci_ptr->C2 |= UART_C2_RE_MASK;
}
break;

 

 

Regards

Daniel

View solution in original post

0 Kudos
Reply
4 Replies
2,859 Views
AA7
Contributor I

I am getting IO_ERROR_INVALID_IOCTL_CMD, is it possible IO_IOCTL_SERIAL_DISABLE_RX is not implemented in MQX 3.8?

0 Kudos
Reply
2,851 Views
danielchen
NXP TechSupport
NXP TechSupport

Sorry I only have MQX 4.2 installed on my PC.

Please refer to the implement in MQX 4.2

 

serial.h

 

#define IO_IOCTL_SERIAL_DISABLE_RX _IO(IO_TYPE_SERIAL,0x17)
#define IO_IOCTL_SERIAL_WAIT_FOR_TC _IO(IO_TYPE_SERIAL,0x18)

 

sel_pol_kuart.c


case IO_IOCTL_SERIAL_DISABLE_RX:
if( *(bool *)param_ptr == TRUE )
{
/* disable receiver */
sci_ptr->C2 &=~UART_C2_RE_MASK;
}
else
{
/* enable receiver */
sci_ptr->C2 |= UART_C2_RE_MASK;
}
break;

 

 

Regards

Daniel

0 Kudos
Reply
2,835 Views
AA7
Contributor I

I ported the code to 3.8 and is all ok. Thanks for your help.

0 Kudos
Reply
2,876 Views
danielchen
NXP TechSupport
NXP TechSupport

Hi

I would suggest you use I/O control commands.

 

IO_IOCTL_SERIAL_CLEAR_STAT :  Clear the statistics.

IO_IOCTL_SERIAL_SET_BAUD:      Set the BAUD rate.

IO_IOCTL_SERIAL_DISABLE_RX:   Disable or enable UART receiver.

 

Regards

Daniel

0 Kudos
Reply