How to activate a 1 second PIT?

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

How to activate a 1 second PIT?

5,195 Views
vokuit00
Contributor I
Hi,

i am too stupid to program a working PIT which calls every second a interrupt service routine on a 52233DEMO board.

Can anybody explain me the code to do that?

Thanks

Volker
Labels (1)
0 Kudos
7 Replies

1,209 Views
airswit
Contributor III
you have to remember to set the ipl for the interrupt, and set the handler.
this is some code i used on my 5213ev board to setup ~100Hz interrupt:

MCF_INTC_ICR55 = 0
| MCF_INTC_ICR_IP(2)
| MCF_INTC_ICR_IL(2); //set priorities
MCF_INTC_IMRH &= ~ MCF_INTC_IMRH_MASK55;

MCF_PIT0_PMR = 24; //set modulus to 24 (about 100Hz frequency-> = 80MHz/(32768*24))
MCF_PIT0_PCSR = 0
| MCF_PIT_PCSR_PRE(0xA)
| MCF_PIT_PCSR_PIE
| MCF_PIT_PCSR_EN
| MCF_PIT_PCSR_RLD; //enable PIT (32768 prescaler, interrupts)


and i manually set the sr in the vectors.s file
0 Kudos

1,209 Views
vokuit00
Contributor I
I tried it with:

MCF_INTC_ICR55(1) = 0
| MCF_INTC_ICR_IP(2)
| MCF_INTC_ICR_IL(2); //set priorities
MCF_INTC_IMRH(1) &= ~ MCF_INTC_IMRH_MASK55;

MCF_PIT0_PMR = 24; //set modulus to 24 (about 100Hz frequency-> = 80MHz/(32768*24))
MCF_PIT0_PCSR = 0
| MCF_PIT_PCSR_PRE(0xA)
| MCF_PIT_PCSR_PIE
| MCF_PIT_PCSR_EN
| MCF_PIT_PCSR_RLD; //enable PIT (32768 prescaler, interrupts)

but it doesn_t work. The isr is set manually in the vectors.s.

No one there using a 52233DEMO-Board and can make an example?

Thanks

Volker
0 Kudos

1,209 Views
airswit
Contributor III
this is a silly question, but do you have interrupts enabled? and are any other interrupts higher priority and thus interrupting all the time?
0 Kudos

1,209 Views
vokuit00
Contributor I
IRQs are enabled, but the only IRQ i can trigger is IRQ7 from a switch SW2 on the demo board.

I tried IRQs for PITs, RTC and DMA Timer, but i am not be able to get success.

I tried it with the help of the software "Coldfire Init", but also without success.

So a CodeWarrior-Example for a 52233 will be very helpful.

Thanks

Volker
0 Kudos

1,209 Views
SimonMarsden_de
Contributor II
The code generated by "ColdFire Init" leaves the interrupt mask in the Status Register (SR) set to 0x7 - i.e. all interrupts except level 7 masked. This is done so that you can write any further initialisation code before finally enabling interrupts.

Maybe this is the problem? If so, you need to lower the interrupt fence to 0 to allow all interrupts. In assembler this would be:

move.l #$00002000,d0
move.w d0,SR


or in C (depending on the compiler) something like:

asm {
move.l #0x00002000,d0
move.w d0,SR
}


Try adding this to the end of your initialisation code.
0 Kudos

1,209 Views
vokuit00
Contributor I
Hi Simon,

many thanks for your helpful answer. That was the problem. Insert Smilies

And the same setting for the SR-Register was in the vector.s-file when usind CodeWarrior-Projects, so i change it there and now it works.

Greetings

Volker
0 Kudos

1,209 Views
SimonMarsden_de
Contributor II
You're welcome.


Simon
0 Kudos