Interrupt don't work

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Interrupt don't work

3,863 Views
kedja
Contributor I
Hi all,
I'm novice and i want to make an interrupt but this don't work...
In main.c
Code:
/* * main implementation: use this sample to create your own application * */#define __interrupt__   __declspec(interrupt)#include "support_common.h" /* include peripheral declarations and more */#include "MCF52235_GPIO.h"#if (CONSOLE_IO_SUPPORT || ENABLE_UART_SUPPORT) /* Standard IO is only possible if Console or UART support is enabled. */#include <stdio.h>#endifextern __interrupt__ void timer_handler(void);__interrupt__void timer_handler(void){ MCF_GPIO_PORTUB=0; MCF_GPIO_PORTUB^=0x01; MCF_PIT0_PCSR=0x109; MCF_PIT0_PCNTR=0x1F4;}int main(void){  mcf5xxx_irq_enable();  MCF_GPIO_PORTUB=0; MCF_GPIO_DDRUB=0x06;  while(1) {  MCF_GPIO_PORTUB^=0x02;  }}

 
In mcf52235_vector.s

Code:
...#define _timer_handler  timer_handler... .extern _timer_handler...vector77: .long _timer_handler...

 The timer_handler function isn't execute by processeur :smileysad:
Thank a bunch
Sorry for my bad english and my hopelessness :smileyhappy:



Message Edited by kedja on 2008-06-11 10:20 AM
Labels (1)
0 Kudos
11 Replies

918 Views
kedja
Contributor I
Ok sorry i have find some source references :smileywink: which was helpful.
But i have some error that i don't explain....


Code:
#ifndef __TIMER_H__#define __TIMER_H__/* FUNCTION: GPTA_Timer_Init() * * Initialise and enable General Purpose Timer A0 to work like * a PIT. * * PARAM2: Prescaler value - sets the tick frequency to *     (system clock/2) divided by 2^PCSR * * PARAM3: Modulo counter - sets the mumber of ticks per interrupt * * PARAM4: Interrupt handler * * RETURNS: none */#include "MCF52235.h"#define ADDRESS   uint32voidGPTA_Timer_Init(uint8 PCSR, uint16 PMR, void (*handler)(void)){ // At 64MHz: // PCSR = 5 gives a tick per uS // PMR = 1000 gives an interrupt every 1ms  uint8 ipl = MCF_INTC_ICR_IL(2)    | MCF_INTC_ICR_IP(0); // Disable timer A MCF_GPTA_GPTSCR1 = 0; // Set up interrupt handler mcf52235_interrupt_init(44, ipl, handler); //  /!\Error 2/!\ // Set modulo count // (= number of ticks per interrupt) MCF_GPTA_GPTC0 = PMR; // Tick frequency = (system clock/2) divided by 2^PCSR MCF_GPTA_GPTSCR2  = (uint8)(MCF_GPTA_GPTSCR2_PR(PCSR)); MCF_GPTA_GPTIOS = MCF_GPTA_GPTIOS_IOS0; MCF_GPTA_GPTIE = MCF_GPTA_GPTIE_CI0; MCF_GPTA_GPTFLG1 = MCF_GPTA_GPTFLG1_CF0; MCF_GPTA_GPTFLG2 = MCF_GPTA_GPTFLG2_TOF;  // Enable timer A MCF_GPTA_GPTSCR1= 0x80;      }/* FUNCTION: mcf52235_interrupt_init() * * Initialise an interrupt handler for an interrupt source * for INTC0. If the handler is a NULL pointer, then mask * this interrupt. * * PARAM1: Interrupt source (1..62) * * PARAM2: Interrupt level and priority * * PARAM3: Interrupt handler * * RETURNS: none */voidmcf52235_interrupt_init(uint8 source, uint8 ipl, void (*handler)(void)){     //  /!\Error 1/!\ // Only for user defined vectors in INTC0 if ((source > 0) && (source < 63)) {  // Interrupts should be disabled to avoid vector problems  // and to ensure that a spurious interrupt exception can't  // be generated.  uint8 sysint =(uint8) asm_set_ipl(7);  if (handler)  {   // Set interrupt priority level   MCF_INTC0_ICR(source) =(uint8)(ipl & 0x3F);   // Set vector   mcf5xxx_set_handler(source+64, (ADDRESS)handler);   // Clear mask for this handler   if (source < 32)    MCF_INTC0_IMRL &= ~(MCF_INTC_IMRL_INT(source)          | MCF_INTC_IMRL_MASKALL);   else   {    MCF_INTC0_IMRL &= ~(MCF_INTC_IMRL_MASKALL);    MCF_INTC0_IMRH &= ~(MCF_INTC_IMRH_INT(source));   }  }  else  {   // Set vector   mcf5xxx_set_handler(source+64, (ADDRESS)handler);   // Set mask for this handler   if (source < 32)   {    MCF_INTC0_IMRL |= MCF_INTC_IMRL_INT(source);   }   else   {    MCF_INTC0_IMRH |= MCF_INTC_IMRH_INT(source);   }  }  // As you were...  asm_set_ipl(sysint); }}/********************************************************************/#endif


 Error generated:

       Error1: identifier 'mcf2235_interrupt_init(...)' redeclared as 'void(unsigned char, unsigned char, void (*)())'
       timer.h line 67 {

       Error2: identifier 'mcf2235_interrupt_init(...)' was originally declared as 'int(...)'
       timer line 34 mcf52235_interrupt_init(44, ipl, handler);

All support is welcome, thanks a bunch
0 Kudos

918 Views
kedja
Contributor I
P.S: I use a ColdFire MCF52235RM and CodeWarrior 7.0. And sorry for tripple post :smileyindifferent:


Message Edited by kedja on 2008-06-12 10:21 AM
0 Kudos

918 Views
fferraro
Contributor II

possibly another point of the program or in file.h is declared :

int mcf52235_interrupt_init ( ..... )

while here is declared: 

void mcf52235_interrupt_init ( ..... )

0 Kudos

918 Views
kedja
Contributor I
Unfortunately isn't that...
Nowhere else i use or defined this function :s
Nice try :smileywink:
thanks
0 Kudos

918 Views
fferraro
Contributor II

has this function the prototype?

0 Kudos

918 Views
kedja
Contributor I
No, was that...:smileyvery-happy: I'm so idiot :smileysad:
0 Kudos

918 Views
kedja
Contributor I
Why when i change the modulo count, the frequency don't change?
I blink a LED and i check with an oscilloscope and i get these result:

for PCSR= 8
and PMR=0 :
    Time LED on=2ms
    Time LED off=11ms

for PCSR=8
and PMR=65535 :
    Time LED on=2ms
    Time LED off=11ms
Is it normal?
0 Kudos

918 Views
kedja
Contributor I
Up! :smileyhappy:
0 Kudos

918 Views
kedja
Contributor I
10 days and always no support :smileysad:
0 Kudos

918 Views
CrasyCat
Specialist III
Hello
 
Forum is probably not the most appropriate place to ask for timely answers to support questions.
 
If you need someone to look at your question I would recommend you to submit a service request for that.

Click here to submit a service request.

Make sure to attach a reproducible project and installed product information to the service request.
To generate the required information:
- Start CodeWarrior
- Open the project
- Select "Help" -> "Pack and Go" and follow instructions on the screen.

Attach the generated .zip file to the SR.
 
CrasyCat
0 Kudos

918 Views
kedja
Contributor I
ok thanks, i've post on the  68K/ColdFire® Microprocessors
and i have support.
thanks a bunch
0 Kudos