This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

sEOS running a dummy tast

Hi,

Please, any one can help me to explain the following function:
Q1) Function X_Init
Q2) Function X
Q3) Function sEOS_ISR()
Q4) Function sEOS_Go_To_Sleep

Code:
#include <reg52.h>

#define OSC_FREQ (12000000UL)
#define OSC_PER_INST (12)

void sEOS_Init_Timer2(const unsigned char);
void sEOS_Go_To_Sleep(void);
void X_Init(void);
void X(void);
void X_Init(void);

#define INTERRUPT_TIMER_2_Overflow 5

void main(void)
{
X_Init(); // prepare for dummy task

sEOS_Init_Timer2(60); // set up simple EOS (60ms tick interval)

while(1)
{
sEOS_Go_To_Sleep();
}
}

void X_Init(void)
{
// Dummy task init function
// Dummy task init...
}

void X(void)
{
// Dummy task called from sEOS ISR
// Dummy task....
}

void sEOS_ISR() interrupt INTERRUPT_TIMER_2_Overflow
{
TR2 = 0;
X();
}

void sEOS_Init_Timer2(const unsigned char TICK_MS)
{
unsigned long Inc;
unsigned int Reload_16;
unsigned char Reload_08H, Reload_08L;

T2CON = 0x04;

Inc = (TICK_MS * (OSC_FREQ/1000)) / OSC_PER_INST;
// Inc = 60,000 = 0xEA60
Reload_16 = (65536UL - Inc); // Reload_16 = 5536 =0x15A0

Reload_08H = (Reload_16 / 256);
Reload_08L = (Reload_16 % 256);

TH2 = Reload_08H; // 0x15
RCAP2H = Reload_08H;
TL2 = Reload_08L; // 0xA0
RCAP2L = Reload_08L;

ET2 = 1;
TR2 = 1;

EA = 1;
}

void sEOS_Go_To_Sleep(void)
{
PCON |= 0x01; // enter idle mode (generic 8051 version)
}


Thank You

Parents Reply Children
  • Sorry...

    ha... why i always type wrong..

    is "cancel function 1) and 2)"

  • Please, any one can help me to explain the following function

    If you can't explain it, why did you code it that way.

    If the reason you need it explained is that it is "inherited" code, do like most of us: if you do not understand it, recode it.

    Erik

  • Hi,

    The code is like that if i cancel the function X and X_Init, so what are the different between the bellow code and the original code??

    #include <reg52.h>

    #define OSC_FREQ (12000000UL)
    #define OSC_PER_INST (12)

    void sEOS_Init_Timer2(const unsigned char);
    void sEOS_Go_To_Sleep(void);
    void X_Init(void);
    void X(void);
    void X_Init(void);

    #define INTERRUPT_TIMER_2_Overflow 5

    void main(void)
    {
    sEOS_Init_Timer2(60); // set up simple EOS (60ms tick interval)

    while(1)
    {
    sEOS_Go_To_Sleep();
    }
    }

    void sEOS_ISR() interrupt INTERRUPT_TIMER_2_Overflow
    {
    TR2 = 0;
    }

    void sEOS_Init_Timer2(const unsigned char TICK_MS)
    {
    unsigned long Inc;
    unsigned int Reload_16;
    unsigned char Reload_08H, Reload_08L;

    T2CON = 0x04;

    Inc = (TICK_MS * (OSC_FREQ/1000)) / OSC_PER_INST;
    // Inc = 60,000 = 0xEA60
    Reload_16 = (65536UL - Inc); // Reload_16 = 5536 =0x15A0

    Reload_08H = (Reload_16 / 256);
    Reload_08L = (Reload_16 % 256);

    TH2 = Reload_08H; // 0x15
    RCAP2H = Reload_08H;
    TL2 = Reload_08L; // 0xA0
    RCAP2L = Reload_08L;

    ET2 = 1;
    TR2 = 1;

    EA = 1;
    }

    void sEOS_Go_To_Sleep(void)
    {
    PCON |= 0x01; // enter idle mode (generic 8051 version)
    }