In a course I am taking on embedded systems, I program LPC1768s which are based on ARM using C.
The main functions are always of int
return type. However, there are no return statements in the end like a return 0
.
I believe this may have something to do with the infinite while loops that these programs use because the controller is never really able to reach the return statement. However, I thought that as this is C, there might be errors, though it turned out that I was wrong.
Just for reference, here is the main function of a program trying to use UART
int main (void)
{
SystemInit();
GPIO_PinDirection(LED1,OUTPUT); /* Configure the pins as Output to blink the Leds*/
GPIO_PinDirection(LED2,OUTPUT);
TIMER_Init(0,100000); /* Configure timer0 to generate 100ms(100000us) delay*/
TIMER_Init(1,500000); /* Configure timer1 to generate 500ms(500000us) delay*/
TIMER_AttachInterrupt(0,myTimerIsr_0); /* myTimerIsr_0 will be called by TIMER0_IRQn */
TIMER_AttachInterrupt(1,myTimerIsr_1); /* myTimerIsr_1 will be called by TIMER1_IRQn */
TIMER_Start(0); /* Start the Timers */
TIMER_Start(1);
while(1)
{
//do nothing
}
}