Sign in

username:

password:



Not a member?

Search 68hc12



Search tips

Subscribe to 68hc12



68hc12 by Keywords

68HC1 | 812A4 | 9S12DP256 | Bootloader | CodeWarrior | D60A | Debugger | DP256 | ECT | EEPROM | EVB | Flash | HC1 | HCS12 | I2C | IAR | ICC1 | Interrupts | LCD | M68KIT912DP256 | MC9S12DP256 | MC9S12DP256B | Metrowerks | Motor | MSCAN | Multilink | PLL | Quadrature | SDI | SPI | Transceiver | XFC

Ads

Discussion Groups

Discussion Groups | 68HC12 | Re: Timer Capture Interrupts Please Help

Join our technical discussions about Freescale Microcontrollers: M68HC12. (Freescale Semiconductor is a Subsidiary of Motorola).

Timer Capture Interrupts Please Help - scca...@yahoo.com - May 16 19:31:39 2007

Hello,
I've been trying to figure this out for some time now and think I'm having a little trouble with the concept in addition to some other details.

I'm trying to get a timer capture interrupt working on my cards12 (mc9s12d64) using ICC12 and a NoIce Debugger. At this point, I'm just trying to get the interrupt working and then eventually will want to time stamp a 5V pulse coming into the controller.

I've set up my vector table so in vectors.c:
extern void TC7Handler(void);
#define DUMMY_ENTRY (void (*)(void))0xF000
#pragma abs_address:0xFFD4

void (*interrupt_vectors[])(void) = {
.
.
.
TC7Handler, /* HC12 TC7 */
.
.
_start};

I initialize my interrupt handler in interrupt.c:

#pragma interrupt_handler TC7Handler
void TC7Handler(void){
TFLG1 = 0x80; // TC7 interrupt acknowledge
PORTA^=0xFF; //toggle PORTA
}
void TC7init(void){
TIOS = 0x00; //initialize as input captures
TSCR1 = 0x80; //enable capture timer
TIE = 0x80; //enable interrupt for channel 7
}

Do you call the interrupt initializer in main? When I try, I get an error saying illegal expression and too many arguements despite there being no arguements.

If anyone could help me with this I would greatly appreciate it. I've read through a rediculous amount of manual information and other posts trying to understand what is going on, but have had no luck so far.

Also, where does TFLG need to be reset (I think to 1) in order to clear the flag?

Any help is appreciated,
Sean


(You need to be a member of 68hc12 -- send a blank email to 68hc12-subscribe@yahoogroups.com )


Re: Timer Capture Interrupts Please Help - Edward Karpicz - May 17 0:56:35 2007

you wrote:

> Hello,
> I've been trying to figure this out for some time now and think I'm having
> a little trouble with the concept in addition to some other details.
>
> I'm trying to get a timer capture interrupt working on my cards12
> (mc9s12d64) using ICC12 and a NoIce Debugger. At this point, I'm just
> trying to get the interrupt working and then eventually will want to time
> stamp a 5V pulse coming into the controller.
>
> I've set up my vector table so in vectors.c:
> extern void TC7Handler(void);

> #define DUMMY_ENTRY (void (*)(void))0xF000
> #pragma abs_address:0xFFD4

D64 vector table starts at FF80, you have to rewrite your own
interrupt_vectors table that matches D64.

>
> void (*interrupt_vectors[])(void) = {
> .
> .
> .
> TC7Handler, /* HC12 TC7 */
> .
> .
> _start};
After some mods above concept of vectors table could be fine for pure S12
chips (I'll explain later why). To adapt what you have to D64 you must open
D64 device guide 9S12DJ64DGV1.pdf and search for "vector table". It's in
chapter 5. For example you'll find that TC7 vector address is FFE0, RESET
vector address is FFFE. For just these two you may write

void _start(void);

#pragma abs_address:0xFFFE
void (*rstvct)(void)=_start;
#pragma end_abs_address

#pragma abs_address:0xFFE0
void (*tc7vct)(void)=TC7Handler;
#pragma end_abs_address

Now about cards12. Are you using it's TwinPEEKs monitor? If you didn't erase
it then you have to deen with interrupt vectors jump table in RAM. Check the
cards12 manual and fine there the address of jump table entry of TC7 vector.
Then before enabling interrupts

#define TC7ramvector xxxx
main()

{

...

*(char*)TC7ramvector = 6; // JMP opcode

*(shotr*)(TC7ramvector+1) = (short)TC7handler;

It should be explained in cards12 manual.

>
> I initialize my interrupt handler in interrupt.c:
>
> #pragma interrupt_handler TC7Handler
> void TC7Handler(void){
> TFLG1 = 0x80; // TC7 interrupt acknowledge
> PORTA^=0xFF; //toggle PORTA
> }
> void TC7init(void){
> TIOS = 0x00; //initialize as input captures
> TSCR1 = 0x80; //enable capture timer
> TIE = 0x80; //enable interrupt for channel 7
> }
>
> Do you call the interrupt initializer in main? When I try, I get an error
> saying illegal expression and too many arguements despite there being no
> arguements.

Make sure function prototypes are visible to compiler before calls or using
pointers to them in the vector table.
>
> If anyone could help me with this I would greatly appreciate it. I've read
> through a rediculous amount of manual information and other posts trying
> to understand what is going on, but have had no luck so far.
>
> Also, where does TFLG need to be reset (I think to 1) in order to clear
> the flag?

ECT block guide is your friend. Usualy we clear TFLG1 bits before enabling
TCx interrupt, also in the TCx interrupt handler. What's missing in your
input capture code is a piece of setup that tells timer which edge you want
to capture: rising/falling or both. You will find it in the ECT block guide

Regards

Edward

>
> Any help is appreciated,
> Sean
> Yahoo! Groups Links
>


(You need to be a member of 68hc12 -- send a blank email to 68hc12-subscribe@yahoogroups.com )