How to communicate RS485 on FRDM KE04?

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

How to communicate RS485 on FRDM KE04?

750件の閲覧回数
vikranthnk
Contributor I

I am using FRDM-KE04Z dev board with onboard MKE04Z8VFK4 MCU, I am trying to communicate serial UART0 using RS485 communication, While debugging mode it will work fine. Plz, help me on how to solve this.

I am using UART0 PTB1(TX), PTB0(RX);  SDK_2.3.1_FRDM-KE04Z

following is my code

int main(void)
{
uart_config_t config;
uint8_t u8Ch = 0;

/* Define the init structure for the output LED pin*/
gpio_pin_config_t led_config = {
kGPIO_DigitalOutput, 0,
};

/* Init output LED GPIO. */
GPIO_PinInit(kGPIO_PORTA, 2U, &led_config); // configured GPIO PTA2 pin for rs485 communication


BOARD_InitPins();
BOARD_BootClockRUN();


UART_GetDefaultConfig(&config);
config.baudRate_Bps = BOARD_DEBUG_UART_BAUDRATE;
config.enableTx = true;
config.enableRx = true;

UART_Init(DEMO_UART, &config, DEMO_UART_CLK_FREQ);

/* echo chars received from terminal */
while(1)
{
  int i =0;
  GPIO_PinWrite(kGPIO_PORTA, 2U, 0u); // writing LOW for enable receiver mode
  u8Ch = UART_GetChar(UART0);

  GPIO_PinWrite(kGPIO_PORTA, 2U, 1u); // writing High for transmit mode
  UART_PutChar(UART0, u8Ch);
}
}

0 件の賞賛
1 返信

428件の閲覧回数
kerryzhou
NXP TechSupport
NXP TechSupport

Hi customer,

   What's the detail problem you are meeting now?

  As I know, after you establish your RS485 hardware, then you need to add the R/D pin control.

  When you want to send, you need to enable the send pin, when you want to receive the data, you need to enable the receive pin, actually, just add the GPIO control, the UART code you still can use the official code.

  In your code, I find you also add the GPIO control, so now, what's the detail problem you are meeting now? You need to test your GPIO control, make sure your GPIO can be pull low and high.


Have a great day,
Kerry

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 件の賞賛