Wednesday, December 28, 2011

PIC: MainStarter

Module: MainStarter

Main program. Waits for an initialization from the DCM to start to send data as well as it terminates communication upon a request to stop from the DCM.

Uses

    p18cxxx.h
    delays.h
    math.h
    init.h
    AnalogToDigital.h
    SerialCommunication.h
    pacingVooMode.h

Type

Access Programs

    None

Implementation

Var
    char packet
    unsigned char function_code
    unsigned char    flag

while (1) {

/* If the receiving buffer is not empty and there is enough
   space in the sending buffer */

        if (checkCondition() == 1){

                   on_uart(&Packet[0]);
                flag=1; // set flag to 1 whenever a packet is received.
                }
/* If the receiving buffer is not empty and there is enough
   space in the sending buffer and the flag is 1  */  

         if (checkCondition2(flag) == 1){

/* start transmitting packets when checkSum
 content is fine and fn_code is egram.*/

                if (Packet[1] == k_egram )        
                         on_timer0();   

/* stop transmitting packets when the fn_code is estop and set first packet to false*/

                else if(Packet[1] == k_estop) {
flag = 0;
setInitialPacket(0);
               }
c_Vp_function(getp_lowRateInterval(), getp_vPaceAmp(), getp_vPaceWidth());
           }
                                        Start/Stop Tr
Check Packet[1] == k_egram    Start
Check Packet[1] == k_estop    Stop

No comments:

Post a Comment