Simple interrupt sample

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Simple interrupt sample

4,151 次查看
Kaare
Contributor III

Hi,

 

I have been using the past two days just to get our new MCF51AC256 to run a simple piece of software. We use Codewarrior 10 (Eclipse based version).

 

Just to learn the MCU i created a simple C project wich configures the RTI to run every 1mS. Then inside the interrupt i toggle an LED output everytime a static counter reaches 500.

 

However, the interrupt is never called and i can't find any working source of information about how to setup a simple interrupt routine in the confusing documentation!

 

Also, i can't seem to grasp the difference between exceptions and interrupts as the 8-bit MCU's we've been working with until now never had anything called exceptions.

 

Last thing, if i use the keyword interrupt, _interrupt, _interrupt_ or _declspec(interrupt) eclipse marks it as syntax error.

 

So could someone please provide a simple, working example of how to use for example the RTI interrupt in a C project within CW 10?

 

Thanks in advance

标签 (1)
标记 (1)
0 项奖励
回复
5 回复数

1,677 次查看
CrasyCat
Specialist III

Hello

Did you consider creating a project with Processorexpert Enabled and adding a TimerInt Bean using RTI peripheral?

This should give you an example on how to implement your interrupt.

And do not care about the orange triangle notifying a syntax error.

Current version of IDE does not recognize the extension keyword added for embedded compiler support (like interrupt, asm , ...).

You should be able to build your application if interrupt keyword is used appropriately.

CrasyCat

0 项奖励
回复

1,677 次查看
Kaare
Contributor III

Goodmorning,

 

Yes i tried that with no success either. In the interrupt vector table (const tIsrFunc _InterruptVectorTable[120] @0x00000000) it has added my interrupt routine isrRTI.

 

This is how the RTI is set up:

 

 

void RTI1_Init(void){  /* SRTISC: RTIF=0,RTIACK=1,RTICLKS=1,RTIE=1,??=0,RTIS2=1,RTIS1=1,RTIS0=0 */  setReg8(SRTISC, 0x76);                }

 

and in events.c i have the following defined:

 

 

ISR(isrRTI){        // NOTE: The routine should include the following actions to obtain        //       correct functionality of the hardware.        //        //       You should write 1 to RTIACK to clear RTIF. Writing 0 has no meaning or effect.        //       Example:   SRTISC_RTIACK = 1;  SRTISC_RTIACK = 1;   }

 

However, if i add a breakpoint on SRTISC_RTIACK i never get a break.

 

I also made sure that i have not masked any interrupt level out in the debugger eg. the mask interrupt checkbox is unchecked.

 

 

I do not understand why it is such a problem to make a simple isr on coldfire? Until now we've been using the HCS08 QE128 and QG8 where i just do this to add an isr:

 

 

interrupt VectorNumber_rti void isrRTI(){}

 

Is it not possible todo the same thing on coldfire V1's?

 

 

 

0 项奖励
回复

1,677 次查看
Kaare
Contributor III

I found the source of the problem! It does not invoke the isr when i set the RTI to use the external clock. I use an external 32.768KHz crystal as clock to our MCU.

 

I will post the solution when i've looked a bit more on this.

0 项奖励
回复

1,677 次查看
Kaare
Contributor III

Ok, the problem is not related to Codewarrior. I can't seem to get the MCU to switch over to FEE mode.

 

I have described my problem in the following thread instead: Cannot get MCF51AC256 into FEE mode

0 项奖励
回复

1,677 次查看
Kaare
Contributor III

I still can't get the RTI to run if i set it to use the external 32.768KHz clock!

 

I solved my problem with entering FEE mode, but i still can only get the RTI to run from the internal 1KHz clock.

 

If i do this:

 

SRTSC = 0x56;

 

Then i get a RTI interrupt every 512mS which is correct.

 

However if i set SRTSC = 0x37, then i never get a RTI interrupt.

 

I simply don't know what to do to get this simple RTI to run on the external clock!!

 

Oh, and before someone says that i need to enable MCGERCLK, the reference manual clearly shows on page 1-7 figure 1-3 that the RTI module gets it clock from either LPOCLK or OSCOUT directly from the OSC module.

0 项奖励
回复