Same code for ATmega2560 works on Arduino Sketch but doesn't work on Microchip Studio

#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!

Upvotes: 1

Views: 74

Answers (1)

Mohamed Saied
Mohamed Saied

Reputation: 1

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

Upvotes: 0

Related Questions