3.3 The main() Function
The
main()
function serves as the starting point for a user application. The user’s application defines the body of the main()
function to increase development flexibility. The main()
function must include two essential elements: - A call to the
SYS_Initialize(NULL)
function - It must execute an infinite loop that contains
SYS_Tasks()
, allowing the task scheduler (for example, FreeRTOS) to invoke the next appropriate task handler.
The following code is a typical example of how to implement the main()
function:
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 ); }