AnsweredAssumed Answered

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

Question asked by Ganesh Ramachandran on May 11, 2016
Latest reply on May 25, 2016 by Ganesh Ramachandran

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 2.0 ?
  • 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:

Outcomes