Freescale MC9S12DP256B - Enhanced Capture Timer Module

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

Freescale MC9S12DP256B - Enhanced Capture Timer Module

2,720 Views
admin
Specialist II
Hi,

In my system, the Adapt9S12DP256 board will have to monitor the serial port and keep track the feedback encoder and at the same time produce step pulses to drive the motor driver. So program plan is as follows:
1.  Main program will keep track on the serial port and calculation will be conducted to calculate the number of step to drive the driver and the frequency as well. The number of step and frequency will be used in ECT module.
2.  At the same time, output compare and input capture will be used to drive the driver and count the feedback encoder respectively.

So, is it possible to use PWM module to produce the step pulses rather than Output Compare module in my case?


Below is the simple code to on and off two LEDs which are LED (PTP7) on my Adapt9S12DP256 board and external LED using PTT7/IOC7 every 0.5second. Just want to know whether my understanding on programming the interrupt module for two LEDs correct or not . I haven try this code because I think I left something else. Please correct me if the code is wrong.

Code:
#include <mc9s12dp256.h>

void TOC7_Init(void)
{  asm sei

    TIOS=0x80;    // IOS7 = 1, channel 7 is output compare
    TCTL1=0x40;   // OM7 = 0, OL7 = 1, Toggle output on PTT7/IOC7
    TSCR2=0x0F;   // TCRE = 1, counter reset enable
    // Prescaler = 128 (Timer clock freq = 25MHz/128 = 195.31kHz)

    TC7=48828;    // LED on/off duration = 48828/195.31kHz = 0.25s
    TIE=0x80;     // Timer interrupt enable, C7I=1
    TSCR1=0x90;   // Timer enable TEN=1, fast flag clear TFFCA=1
   
    asm cli;
}

void main()
{
    TOC7_Init();

    DDRP=0xFF;    // Port P as output
    PTP=0x00;     // Initialize LED off
}

// definition
#pragma interrupt_handler TOC7_ISR(); 
void TOC7_ISR(void)
{
    PTP ^= 0x80;  // Toggle output bit (PTP7)
}

// interrupt vector declaration
extern void TOC7_ISR();
#pragma abs_address:0xffee;
void (* TOC7_handler[])() = { TOC7_ISR };
#pragma end_abs_address

I need help on this:
1.  Is the definition and vector declaration of the TOC7_ISR correct ?
2.  Should I include vectors.c file?
3.  "#pragma abs_address:0xffee"  Where is the 'ffee' address based on? As I know, the vector address for ECT channel 7 in the datasheet is ffe0.
4.  How to set the bus clock to the ECT module ? In this example, I assume it to be 25MHz.
5.  What is 'asm sei' and 'asm cli' ?
6.  Will the PTT7/IOC7 output toggle automatically when interrupt occur?
7.  I have enabled the counter reset. So I don't have to add  "TC7 +=
48828" in my ISR because the counter will reset once it match TC7=48828 and interrupt occur. Then it will count again to cause the next interrupt. ( Please correct me if I'm wrong )
Your help is highly appreciated.
Thanks in advance.

best regards,
yj


Message Edited by yj on 2007-12-03 01:17 AM
Labels (1)
0 Kudos
Reply
2 Replies

606 Views
Xbot
Contributor II
 y not supply the link then...?
0 Kudos
Reply

606 Views
bigmac
Specialist III
Hello yj,
 
This post also appears to be present within another thread.  Please do not duplicate your posts.
 
Regards,
Mac
 
0 Kudos
Reply