┬ÁTasker Forum > MODBUS

MODBUS UART pin configure


Dear Mark,
Now I am trying run the uTasker on my customized board with KEAZ128(80PIN).

One modbus slave run on UART0 (on port A) with RS485, and the DEMO_UART on UART2(on port I).

There are few questions about MODBUS and UART .

1. Where to define the GPIO pin  to work as RTS control  when use RS485?

2. How to define UART pin ? The UART2 was used on port I bit0/bit1.
    Read through uTasker_MODBUS.PDF and uTaskerUART.PDF  ,find out that should use macro UARTx_ON_X to define
the UART pin .
     But the macro UART2_ON_I  can't be found . 
    Read the code ,found that  the UART2 was hard code to  port D .
    In file  "kinetis_uart.h" line 1906 :

        case 2:                                                              // configure the UART Tx 2 pin
            #if defined KINETIS_KE
        _CONFIG_PERIPHERAL(D, 7, (PD_7_UART2_TX | UART_PULL_UPS));       // UART2_TX on PD7 (alt. function 2)

      What's more ,the macro _CONFIG_PERIPHERAL was defined to dummy.
     Do I need manually change the code to configure the UART2 on PORT I?

By the way , there is  one  FRDM-KL27Z and one  FRDM_KEAZ128Q80 board in my hand.  I can try first on that boards.
Could you thrown a simple demo  to run a modbus slave    with RS485, and the DEMO_UART on UART2(on port I).

Best Regards,
Kiger Zhang


For question 1) see http://www.utasker.com/forum/index.php?topic=1944.msg7168#msg7168

2) The UART2 interface supports only UART2 on PTD.
To add control to allow it on PTI the following can be added:

                #if defined UART2_ON_I
        SIM_PINSEL1 |= (SIM_PINSEL1_UART2PS);                            // UART2_TX on PI1
        _CONFIG_PERIPHERAL(D, 7, (PD_7_UART2_TX | UART_PULL_UPS));       // UART2_TX on PD7 (alt. function 2)

                #if defined UART2_ON_I
        SIM_PINSEL1 |= (SIM_PINSEL1_UART2PS);                            // UART2_RX on PI0
        _CONFIG_PERIPHERAL(D, 6, (PD_6_UART2_RX | UART_PULL_UPS));       // UART2_RX on PD6

The _CONFIG_PERIPHERAL() is indeed dummy for KE parts but it allows the code to be more readable and also it causes the simulator to update its mux settings.
The defines
    #define PI_0_UART2_RX                PORT_MUX_ALT3
    #define PI_1_UART2_TX                PORT_MUX_ALT3
can be added or else these can simply be removed.

It will make no difference on the HW. The simulator won't handle this in the open source version (it will still display the PTD pins being used) but it is handled in the developer's version.




[0] Message Index

Go to full version