external irq on a mc9s08rd32

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

external irq on a mc9s08rd32

5,987 Views
jah
Contributor I
-is there an i/o pin for a external irq other than the keyboard interrupts on this part?
-is there a document (provide link) that outlines the function of each pin of the mc9s08rd32?
-can a timer, comparator, or spi be made to provide a interruptable io pin?

thanks!
Labels (1)
0 Kudos
10 Replies

474 Views
jah
Contributor I
thanks for pointing out the common TPM sections vs the channel sections. Not alot of empahsis in the manual on this.
http://www.freescale.com/files/microcontrollers/doc/data_sheet/MC9S08RG60.pdf

I GOT THIS TO WORK AND WILL POST METHODS FOR PEEPS NEEDING THIS TOO. BOTH HERE AND ON THE SECOND THREAD TOO.

DISCUSSION:
Only 32/44/48pin hs08 processors have an external interrupt PTD2/IRQ. NOTE: MC9S08RC/RD/RE/RG processors have KBI interrupt modules. These get used up quick for a keyboard matrix and if you need antoher dedicated interrupt read on:


METHOD:
With respect of a TPM common counter and its connected independant channel units, the 28pin mc9s08dr32dwe has one main unit and two channels working of the main unit. The TPM overflow interrupt vector6, is common to channel 0&1 and is not efficient because its dependencies tie up two channels. 4example use only one channel, use vector4 for TPM zero input captre (your external interruptable pin PTD6/TPM1CH0) and you can still use vector5 on channel one as a continous running timer via the output compare mode.
//consider the code below as 90% fucntional
//***********Timer chan0&1 Initiliaztion**************************
TPM1SC = 0x08; //setup common ch1&0 control reg, clr TPM1CNTx
//clock=bus, scale=1, pwm=off, overflow irq=off
TPM1C0SC=0x48; //set ch0 as input capture w/ irq
//irq=on, PTD6/TPM1CH0=in capture mode, -e.
TPM1C1SC=0x90; //set ch1 as output compare, irq=off,
//output compare=on, softwre compare=on.
//*************setup interrupt vectors***********************
VECTOR 4 TPM0InputCaptre_ISR
VECTOR 5 TPM1OutputCompare_ISR
//******************
//*************interrupt service routines*************
interrupt 4 void TPM0InputCaptre_ISR (void){
TPM1C0SC = TPM1C0SC; //2part irq reset thingy.
TPM1C0SC &= 0x7F;
FlagTPM0InputCaptre++;} //report irq status to main emulation
interrupt 5 void TPM1OutputCompare_ISR (void){
TPM1C1SC = TPM1C1SC; //2part irq reset thingy.
TPM1C1SC &= 0x7F;
FlagTTPM1OutputCompare++;} //report irq status to main emulation.
//**********************
***************usage as continus timer on TPM1*************
void Wait500ms (void){
TPM1MODH = 0x1E; //with 8MHz OSC, Timer1 goes every 0.001 s
TPM1MODL = 0x84;
TPM1SC = 0x0F; //Set Prescaler = 128
TPM1C1SC=0xD0;} //enable tpm1 for irq on output compare.
for(FlagTTPM1OutputCompare=0;!FlagTTPM1OutputCompare;}; //loop till done.
//*****************

one big bad:
using this scheem as an external irq will not wake the processor from some types of sleep because there is no clock supporting the TPM operation in sleep.
//**********

Message Edited by jah on 2006-08-21 11:13 AM

Message Edited by jah on 2006-08-21 11:14 AM

Message Edited by jah on 2006-08-21 11:14 AM

0 Kudos

474 Views
jah
Contributor I
HELLO everyone Mac, Pavel ok2ucx, David, rocco, everyone... THANKS!

rocco:
already using the KBI inputs as an irp on portA for a keymatrix, part of the project legacy.

David & Pavel ok2ucx:
per the freescale rev1.11 manual page27n (linky below)...
http://www.freescale.com/files/microcontrollers/doc/data_sheet/MC9S08RG60.pdf
the PTD2/IRQ is available only in 32, 44 & 48 pin pkages and the mc9s08rd32dwe is a 28pin device.

QUESTION?????
it looks possible to creat an external irq input pin into this processor by the use of pin23 (ptd6/tpm1ch0). the big bad here is that the control bit tpm1sc/toie/b6 for the overflow interrupt is shared between tpm0 and tpm1 and legacy code uses tpm1 overflow irq already. could the legacy code be modifyed to use tpm1 but not the overflow status irq?

thanks!
0 Kudos

474 Views
peg
Senior Contributor IV

Hi jah,

In the other thread you started on this I thought I already answered this in the last post to it.

If you use 1 pin for the psuedo IRQ it will not affect anything you are doing with the other (including rollover)

There is only one overflow flag/interrupt because there is only one counter!

There is only ONE timer/counter on this device with TWO channels, I believe you are slightly confusing channels with timers. Other devices have multiple timers with multiple channels on each.

Regards David

 

0 Kudos

474 Views
jah
Contributor I
my processor does not have PTD2/IRQ and if fact of port-d only has teh pin PTD6.

thus i assume i do not have a external interrupt pin.


i will need to impliment the input capture interrupt on timer/counter0
0 Kudos

474 Views
peg
Senior Contributor IV

Hi jah,

If you would enlighten us on what package device you are using it would help very much.

I couldn't believe they would drop the IRQ so I took a look myself.

The 28 pin SOIC package does indeed drop PTD2/IRQ

It has Port D 1,2 and 6 also, so I still do not know which one you are talking about.

1 and 2 share with RESET and BKDG so I doubt they don't exist!

As you and others have said there are other pins that can generate an interrupt that can be used like a IRQ if you like.

Be careful of priority though, IRQ is usually highest so the timer would seem the best choice here in this regard.

Regards David

 

0 Kudos

474 Views
jah
Contributor I
"If you would enlighten us on what package device you are using it would help very much."

mc9s08rd32dwe
0 Kudos

474 Views
rocco
Senior Contributor II
Hi, Jah:

That package has eight KBI inputs on port A, each capable of providing the functionality of the IRQ input, although at a lower priority.
0 Kudos

474 Views
jah
Contributor I
-is there an i/o pin for a external irq other than the keyboard interrupts on this part?
NO THERE IS NOT, THE MC9S08RD32 ONLY HAS KEYBOARD IRQ PORTS, NO DIDICATED IRQ LINE

-is there a document (provide link) that outlines the function of each pin of the mc9s08rd32?
HERE IS A LINKY: http://www.freescale.com/files/microcontrollers/doc/data_sheet/MC9S08RG60.pdf

-can a timer, comparator, or spi be made to provide a interruptable io pin?
I THINK SO, CONFIGURE THE TIMERCOUNTER CHAN0= CLOCK=BUS, PWM=OFF, OVERFLOW IRQ = OFF, SETUP INPUT CAPTURE ON CHAN0 FOR A +OR- EDGE DETECTION IRQ



I DONT KNOW IF THE THIRD ITEM WILL WORK, LOOKS POSSIBLE TO GENERATE AN EXTRA EXTERNAL IRQ REPONSE FORM PIN 23 (PTD6/TMP1CH0) BY USING CHAN0 OF THE TIMERCOUNTER.

HAS ANYONE DONE THIS WITH SUCCESS, ESPECIALLY ON THE "RD" PROCESSSOR????
0 Kudos

474 Views
ok2ucx
Contributor IV

Hi there,

there *is* IRQ pin --- but needs to be enabled first (see section 5.8.1 of datasheet, register IRQCS).

Item #3 will work too, any timer channel pin can serve as 'irq' pin using its Input Capture feature (see chapter 10.5.2.1).

Hope it helps, Pavel ok2ucx

 

 

0 Kudos

474 Views
bigmac
Specialist III

Hello,

Suggest you look at the data sheet for the MC9S08RG60 device, available from the Freescale web site.  This also covers the RD series.  I do not quite know what you mean when you refer to an "interruptable I/O pin" for the timer, comparator and SPI peripherals.

Regards,
Mac

0 Kudos