Generation of PWM using Extrenal Interrupts and Timers

Hi everybody,

I'm a beginner trying to generate a PWM wave on a C8051F330 micro controller using C programming language. I have many doubts regarding this exercise. It would be really helpful if someone clarifies my doubtswhich will eventually get me going.

Can anybody please explain me roughly the flow of the following program...??

// Include Files //
// Global constants //
// Function Prototypes //
// Main Routine //

void main (void)
{ PCA0MD &= ~0x40; Oscillator_Init (); Port_Init (); External_Interrupt_Init (); Timer2_Init (); PCA_Init (); EA = 1; while (1);
}

// Oscillator Initialisation //
void Oscillator_Init (void)
{ //do something//
}

//Port Initialisation //
void Port_Init (void)
{ //do something//
}

//External Interrupt Initialisation //
void External_Interupt_Init (void)
{ //do something//
EX0 = 1;
}

//Timer2 Initialisation //
void Timer2_Init (void)
{ TMR2CN=0x00;
TMR2RL= RELOAD_VALUE;
TMR2 = 0xFFFF; // Set to reload immediately //
}

//PCA Initialisation //
void PCA_Init (void)
{ //do something//
}

//Interrupt Service Routine (ISR) //
INTERRUPT(INT0_ISR, INTERRUPT_INT0)
{ TR2 = 1;
}

This program is in C. I'm here trying to understand the program flow. I know that the "main()" is the first function that gets executed here. And then the line "PCA0MD &= ~0x40" followed by Osillator_Init function. The program control actually goes into the called Oscillator_Init function (below main()) and executes it,.and so on...

In case of External_Interrupt_Init(),I have enabled /INT0 interrupt using "EX0=1". Where does the program flow control go from here...??

And in ISR where does the program control go after executing TR2 = 1,.

Please folks help me find answers to my doubts.

Parents
  • So, I see that your teacher have given you a skeleton code for your programming exercise.

    Well, I'm pretty sure that your teacher also is of the belief that students who have been visiting the lessons would also have enough skill to know how to solve this programming exercise. And you have probably also received documentation or links to documentation.

    So exactly where are you stuck? What part of the microcontroller course did you understand, and what part did you fail to understand?

    Have you spent time with the documentation for the processor?

    Have you checked for application notes?

    Have you checked what potentially useful examples there are on the manufacturers home page or installed with the Keil tools? Or available on this site?

Reply
  • So, I see that your teacher have given you a skeleton code for your programming exercise.

    Well, I'm pretty sure that your teacher also is of the belief that students who have been visiting the lessons would also have enough skill to know how to solve this programming exercise. And you have probably also received documentation or links to documentation.

    So exactly where are you stuck? What part of the microcontroller course did you understand, and what part did you fail to understand?

    Have you spent time with the documentation for the processor?

    Have you checked for application notes?

    Have you checked what potentially useful examples there are on the manufacturers home page or installed with the Keil tools? Or available on this site?

Children
More questions in this forum