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

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
  • The questions you're asking are about pretty basic embedded programming concepts - they have nothing specifically to do with Keil, nor even the C8051F330 microcontroller.

    The Keil manuals and microcontroller datasheet, etc, do assume that you are proficient.

    Therefore, especially as this is for your job, I most strongly recommend that you take an embedded training course.

    There are some (providers) mentioned here: http://www.keil.com/events/ (see "Third party training")

    And here: blog.antronics.co.uk/.../08

    You local SiLabs and/or Keil distributors should be able to suggest others - and may even provide training themselves...

Reply
  • The questions you're asking are about pretty basic embedded programming concepts - they have nothing specifically to do with Keil, nor even the C8051F330 microcontroller.

    The Keil manuals and microcontroller datasheet, etc, do assume that you are proficient.

    Therefore, especially as this is for your job, I most strongly recommend that you take an embedded training course.

    There are some (providers) mentioned here: http://www.keil.com/events/ (see "Third party training")

    And here: blog.antronics.co.uk/.../08

    You local SiLabs and/or Keil distributors should be able to suggest others - and may even provide training themselves...

Children
No data