AnsweredAssumed Answered

Writing ISR in basic C for MCF51CN128 [Newbie Question]

Question asked by Ujjwal Gupta on May 23, 2011
Latest reply on May 25, 2011 by Jim Donelson

Hi,

 

I am a student and new to MCUs.

 

I am trying to learn how to use interrupts (say IRQ) using basic C coding. Previously I have worked on ATmel 8 bit MCUs where I could simply write the ISR using the pointer name given in vector table and a predefined function name.

 

Not able to find a similar way in CN128. I have been able to write a simple code for polling the IRQ pin (PC4) and toggling LEDs.  kindly help me, how can I make use of interrupt to toggle LEDs.

 

#include<mqx.h>#include<bsp.h>#include<fio.h>void main(void){    int i=0;    VMCF51CN_STRUCT_PTR reg_ptr = (VMCF51CN_STRUCT_PTR)BSP_IPSBAR;reg_ptr-> GPIO.PTEDD|=(5<<3);          //reg_ptr-> GPIO.PTHDD|=(1<<3);    // Output for LEDsreg_ptr-> GPIO.PTGDD|=(1<<5);    //reg_ptr-> GPIO.PTGDD &= ~(1<<6); //  input (Switch)reg_ptr-> GPIO.PTCDD &= ~(1<<6); //  input (Switch)while(1) { reg_ptr->GPIO.PTED|=(5<<3); reg_ptr->GPIO.PTHD|=(1<<3); reg_ptr->GPIO.PTGD|=(1<<5) | (1 << 6); reg_ptr->GPIO.PTCD &= ~(1<<6); // Delay   i=0;  while(i<2000000)  {    i++;               }  //Polling, If (Any one switch is pressed) if(((reg_ptr->GPIO.PTGD & 0x40) == 0) | (((reg_ptr->GPIO.PTCD & 0x40) >> 6) == 0)) {    reg_ptr->GPIO.PTED &=~( 5<<3);  reg_ptr->GPIO.PTHD &=~( 1<<3);  reg_ptr->GPIO.PTGD &=~( 1<<5);  //Delay     i=0;   while(i<2000000)   {     i++;   }  }}}     

 

Thanks in advance.

Outcomes