Everything
8.5.6 Master Startup

The processing necessary to start up the master is the same as that for a usual program that does not use the PIC/PID function except for the two processes described below. Add these two processes to the startup processing created according to section 7.3, Startup Program Creation.

(1)

Initiation of and Return from Application

Set up the PID register in the main function and branch to the PIC entry address to initiate the application. In addition, a means for returning from the application to the master should be provided.

(2)

Reference to Shared Library Functions to be Used

The shared libraries to be used by the application should be referred to also by the master in advance.

The following shows an example for calling a PIC/PID application from the main function.

This example assumes the following conditions:

-

After application execution, control can be returned to the master through the RTS instruction.

-

The application does not pass a return value.

-

The PID initiation address (PIC_entry) and PID start address (PID_address) for the application are known and fixed when the master is built.

-

R13 is used as the PID register.

-

Initialization of the section areas on the application side is not done on the master side.

-

The application uses only the printf function as the shared library.

Example:

/* Master-Side Program */
/* Initiates the PIC/PID application. */
/* (For the system that the application does not pass */
/*  a return value and execution returns through RTS) */
#include <stdio.h>
#pragma inline_asm Launch_PICPID_Application
void Launch_PICPID_Application(void *pic_entry, void *pid_address)
{
    MOV.L    R2,__PID_R13
    JSR      R1
}
int main()
{
    void *PIC_entry   = (void*)0x500000;  /* PIC initiation address */
    void *PID_address = (void*)0x120000;  /* PID start address */
 
    /* (1) Initiation of and Return from Application */
    Launch_PICPID_Application(PIC_entry, PID_address);
 
    return 0;
}
 
/* (2) Reference to Shared Library Functions to be Used */
void *_dummy_ptr = (void*)printf;  /* printf function */