0
\$\begingroup\$

I am working on a boot loader design for a kinetis controller. I am using this Terminal application ( https://sites.google.com/site/terminalbpp/ ) . I am able to send texts like, " Hello world" through my serial port, by debugging the code using Segger's J link debugger into my board. Sending Text messages

But When I try to send the application file after programming the Board with my boot loader code, The terminal is unresponsive.

Is it because my Serial Connection is half duplex (RS 485) or is it because there is some error in my code ?

I don't know whether half-duplex connection would be a reason. I wanted to know whether that would be a reason. If my question sounds dumb to you, please explain me the logic.

Thanks for helping

Update:

This code provides the output successfully as shown in the image.

for(;;) { GPIO_PDD_TogglePortDataOutputMask(GPIOA_BASE_PTR, GPIO_PDD_PIN_21); CLS1_SendStr("Hello World!\r\n", CLS1_GetStdio()->stdOut); WAIT1_Waitms(1000); CLS1_SendStr("Welcome Ganesh!\r\n", CLS1_GetStdio()->stdOut); } But this code

` static void ReadText(void) { uint8_t buffer[32], ch, i;

      for(;;) {
        GPIO_PDD_TogglePortDataOutputMask(GPIOA_BASE_PTR, GPIO_PDD_PIN_21);
        CLS1_SendStr("Enter some text: ", CLS1_GetStdio()->stdOut);
        GPIO_PDD_TogglePortDataOutputMask(GPIOA_BASE_PTR, GPIO_PDD_PIN_21);
        buffer[0] = '\0';
        i = 0;
        do {
          if (CLS1_KeyPressed()) {
            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_TogglePortDataOutputMask(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);
      }
    }`

It gets debugged into the board without any errors but the in the terminal application there is no change. GPIO_PDD_TogglePortDataOutputMask(GPIOA_BASE_PTR, GPIO_PDD_PIN_21); This piece of code enables and disables the Transmitter while sending and receiving respectively. Am I doing any mistake in usage of this piece of code ?

\$\endgroup\$

2 Answers 2

1
\$\begingroup\$

For RS485 you have to implement hardware handshaking using RTS. When you want to send chars over UART the RTS enables the transmitter, while receiving the RTS disables the transmitter and switches into the receiving mode. RS485 is usually used in master/slave comm. where master sends a query: RTS ON->TX->RTS OFF->RX and slave responds: RX->Is master querying to me?->RTS ON->TX (reponse)->RTS OFF->RX.

\$\endgroup\$
3
  • \$\begingroup\$ Thanks for the info. Now I understand clearly what happens. \$\endgroup\$ Commented May 7, 2016 at 9:56
  • \$\begingroup\$ Hey can you recheck my query and help me ? I have updated it. Thanks \$\endgroup\$ Commented May 9, 2016 at 6:47
  • \$\begingroup\$ Have you tried to find the ready made code for your platform, first? The mistake is that you send the text into UART buffer, but you don't wait the chars are all output (the chars are still xmited from UART when you execute next lines) - you would need ISR for set/reset RTS. Or 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. \$\endgroup\$ Commented May 9, 2016 at 7:38
1
\$\begingroup\$

It's definately possible to send files over half-duplex links, but you will need to use a half-duplex protocol where the sender pauses sending each time it expects a response from the receiver.

\$\endgroup\$
2
  • \$\begingroup\$ Thanks for the info. Yea ill look into the Protocol thing. \$\endgroup\$ Commented May 7, 2016 at 9:55
  • \$\begingroup\$ Hey can you recheck my query and help me ? I have updated it. Thanks \$\endgroup\$ Commented May 9, 2016 at 6:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.