1
#include <SoftwareSerial.h>
void setup() {
  uint8_t ubrr = 103;
  UCSR3A = 0x00;                                //reset; Bd factor is not doubled,
  UCSR3B |= (1 << RXEN3) | (1 << TXEN3);        //Serial transmitter/receiver are enabled
  UCSR3C |= (1 << UCSZ31)|(1 << UCSZ30);        //8-bit character size, 1-StopBit
  UBRR3H = (ubrr >> 8);                         //Bd = 9600
  UBRR3L = ubrr;
}
void UART_Transmit( char data ){
    /* Wait for empty transmit buffer */
    while( !( UCSR3A & ( 1 << UDRE3 ) ) );
    
    /* Put data into buffer, sends the data */
    UDR3 = data;
}
void Terminal_SendString( char *string_Ptr ){
    while( *string_Ptr != '\0' ){
        UART_Transmit( *string_Ptr );
        ++string_Ptr;
    }
}
void loop() {
  constexpr short int T_mSEC = 1000;
  Terminal_SendString("Inside loop() ..\r\n");
  delay(T_mSEC);
}

So regarding the previous code snippet, which is an Arduino Sketch code, it simply attempts to send strings of characters via UART3 in ATmega2560 MCU on an Arduino Mega board (the cloned one that uses CH340 USB-to-TTL chip). It works fine when I send a string in the function Terminal_SendString(), however surprisingly, the same code when ported to a Microchip studio project (previously "Atmel Studio"), taking into consideration the minor changes that shall occur to this Sketch to properly work on Microchip Studio project, it doesn't work at all, meaning that the Rx LED in my USB-to-TTL device I am using, which is Silicon Labs CP210x USB to UART Bridge, doesn't toggle indicating the reception of the string!

N.B: I have tried to test the functionality of Microchip Studio by only toggling an LED, and the code seems to work perfectly fine, however, I face the issue that I have explained when building and downloading the UART3 code using the same IDE!

I need your help in this issue!

0

1 Answer 1

0

It's because there is no main() function it means you are missing the entry point to your application, i don't think it even compiles on Microship IDE

Sign up to request clarification or add additional context in comments.

1 Comment

If you read my explanation of the issue, I have mentioned: "taking into consideration the minor changes that shall occur to this Sketch to properly work on Microchip Studio project", meaning that of course there is a main() function and a super loop and everything that shall make such code work on a bare-metal system like my MCU, I thought you would consider this!

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.