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

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

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

Jump to solution
1,294 Views
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:

Labels (1)
1 Solution
934 Views
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!
-----------------------------------------------------------------------------------------------------------------------

View solution in original post

2 Replies
935 Views
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!
-----------------------------------------------------------------------------------------------------------------------

934 Views
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 Kudos