14.2.2.3 The main() function
The starting point of a User application is the main()
function. The main()
function body is defined by the user's application to make the application development more flexible.
The main()
function must contain two mandatory elements: a call to the SYS_Initialize ( NULL ) function and the infinite loop with SYS_Tasks ( ) inside, which allows the task scheduler (eg: freeRTOS) to call the next appropriate task handler.
A typical main()
function implementation is shown below:
int main ( void ) { /* Initialize all modules */ SYS_Initialize ( NULL ); while ( true ) { /* Maintain state machines of all polled MPLAB Harmony modules. */ SYS_Tasks ( ); } /* Execution should not come here during normal operation */ return ( EXIT_FAILURE ); }