How to send a .s19 file to MKE02Z64VLD2 through a RS 485 (Half duplex) serial connection ?

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

How to send a .s19 file to MKE02Z64VLD2 through a RS 485 (Half duplex) serial connection ?

跳至解决方案
1,562 次查看
ganeshramachand
Contributor IV

I am using this Terminal Application , which can be found in this link TerminalTerminal new.jpg

I have written a code for blinking an LED in my custom board. I converted it into .s19 file using

"Create Flash Image option" . I need to send it to the board through through the RS 485 serial connection between the PC and the Board.

CODE 1:

I tried to run this code for sending strings and got the output successfully after toggling PIN 21.

This is the code:

#include"GPIO_PDD.h"

int main(void)

{

PE_low_level_init();

for(;;) {

   GPIO_PDD_TogglePortDataOutputMask(GPIOA_BASE_PTR, GPIO_PDD_PIN_21);

      CLS1_SendStr("Hello World!\r\n", CLS1_GetStdio()->stdOut);

      CLS1_SendStr("Welcome Ganesh!\r\n", CLS1_GetStdio()->stdOut);

      WAIT1_Waitms(1000);

}

}

OUTPUT:

Terminal output got.jpg

CODE 2:

#include "GPIO_PDD.h"

static void ReadText(void) {

          uint8_t buffer[32], ch, i;

          for(;;) {

            GPIO_PDD_SetPortDataOutputMask(GPIOA_BASE_PTR, GPIO_PDD_PIN_21);

            CLS1_SendStr("Enter some text: ", CLS1_GetStdio()->stdOut);

            buffer[0] = '\0';

            i = 0;

            do {

              if (CLS1_KeyPressed()) {

              GPIO_PDD_ClearPortDataOutputMask(GPIOA_BASE_PTR, GPIO_PDD_PIN_21);

                CLS1_ReadChar(&ch); /* read the character */

                if (ch!='\0') { /* received a character */

                  buffer[i++] = ch; /* store in buffer */

                  if (i>=sizeof(buffer)) { /* reached end of buffer? */

                    buffer[i] = '\0'; /* terminate string */

                    break; /* leave loop */

                  }

                  if (ch=='\n') { /* line end? */

                    buffer[i] = '\0'; /* terminate string */

                    break; /* leave loop */

                  }

                }

              }

            } while(1);

            GPIO_PDD_SetPortDataOutputMask(GPIOA_BASE_PTR, GPIO_PDD_PIN_21);

            CLS1_SendStr("You entered: ", CLS1_GetStdio()->stdOut);

            CLS1_SendStr(buffer, CLS1_GetStdio()->stdOut);

            CLS1_SendStr("\r\n", CLS1_GetStdio()->stdOut);

          }

        }

int main(void)

{

PE_low_level_init();

ReadText();

}

EXPECTED OUTPUT:

TERMITEOUTPUT.png

MY OUTPUT:

The Code builds and gets debugged into the board without any errors but am not getting any output in the TERMINAL APPLICATION.

MY Query:

  • I asked in few forums and they advised me this ” some MCUs have already UART capable of automatic handshake, you do just need to properly initiaize the UART, search the possibilties that your MCU supports, first. Then you would have to use a MCU pin that is predefined as RTS signal. ”
  • So I posted this question in this forum Which is the predefined RTS pin in MKE02Z64VLD2 and How to initialize it using Kinetis Design Studio...
  • SINCE MKE02Z64VLD2 has no RTS Pin, I am clueless as to how to send and receive characters as my connection is a Half Duplex one.
  • Once if I find a way to get the EXPECTED OUTPUT (as shown in the figure), I CAN TRY TO INCORPORATE THE SAME LOGIC IN THE CODE FOR LOADING A S19 file.

NOTE:

标签 (1)
1 解答
1,202 次查看
Jorge_Gonzalez
NXP Employee
NXP Employee

Hello Ganesh Ramachandran:

Sorry for the delayed response. Are you still struggling with this?

Just like you mentioned and as commented in your other post, the UART in KE02 devices does not provide hardware flow control signals. But you can still use GPIOs to control UART send/receive.

Since you are using half-duplex RS485, then I assume you have an external RS-485 IC which should have a way to control transfer direction with a GPIO.

In your code above I see you toggle PTA21. If this pin is intended to control transfer direction then the clear API should be placed before the if(CLS1_KeyPressed()) condition, like next:

GPIO_PDD_ClearPortDataOutputMask(GPIOA_BASE_PTR, GPIO_PDD_PIN_21);

if (CLS1_KeyPressed())

{

...

Let me know if any doubts.

Best Regards!,
Jorge Gonzalez

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

在原帖中查看解决方案

2 回复数
1,203 次查看
Jorge_Gonzalez
NXP Employee
NXP Employee

Hello Ganesh Ramachandran:

Sorry for the delayed response. Are you still struggling with this?

Just like you mentioned and as commented in your other post, the UART in KE02 devices does not provide hardware flow control signals. But you can still use GPIOs to control UART send/receive.

Since you are using half-duplex RS485, then I assume you have an external RS-485 IC which should have a way to control transfer direction with a GPIO.

In your code above I see you toggle PTA21. If this pin is intended to control transfer direction then the clear API should be placed before the if(CLS1_KeyPressed()) condition, like next:

GPIO_PDD_ClearPortDataOutputMask(GPIOA_BASE_PTR, GPIO_PDD_PIN_21);

if (CLS1_KeyPressed())

{

...

Let me know if any doubts.

Best Regards!,
Jorge Gonzalez

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

1,202 次查看
ganeshramachand
Contributor IV

Thanks a lot sir. I ll use your suggestion when I get back to my custom Boot loader. I am now trying my luck with Kinetis Boot loader for MKE02Z64VLD2. Kindly check this thread and give me your valuable suggestions sir.

How to run the application file in the Freescale Universal boot loader ?

0 项奖励
回复