Newbish question on Timer module and valid time settings.

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

Newbish question on Timer module and valid time settings.

Jump to solution
3,204 Views
Telepath
Contributor I
Hi. This is a pretty dumb question I'm sure, but still, if there is an easy way to solve this, please help...

I am involved in making a project for a HC12 and I use TI1 TimerInt bean. This is currently set to an interrupt period of 256us. Now, this baby is supposed to pulse at, say, 10Hz, so obviously I'd be very, very happy if I could somehow set the period to 250us or 1ms, exactly. However these values are not valid due to clock frequency. Is there an easy way to do this?

Happy for any help,

Kindly, Thomas
Labels (1)
Tags (1)
0 Kudos
1 Solution
808 Views
ProcessorExpert
Senior Contributor III
I think there are two options how to set exactly 250us period of the interrupt:

1)
To switch to other periodic interrupt source (e.g  TC0-TC7 or ModulusComp).

2)
To use different value of external clock source instead of 4 MHz (e.g 12.288 MHz). The reason is
the RTIfree (periodic source interrupt) device is directly connected to the oscillator and RTIfree device offers only prescalers as multiple of 1024 therefore the value of external clock source must be a multiple of 1.024 MHz. For closer look please go the the "Clock Path" tab in the Timing dialog window of the TimerInt bean.

The list of all possible values of external source for this case is attached. The red values should be possible easily to buy.

View solution in original post

0 Kudos
11 Replies
808 Views
ProcessorExpert
Senior Contributor III
We need more detailed information to solve your problem. Could you please specify what processor are you using, value in the "Internal bus clock" property, value in the "Clock frequency" property in the CPU bean and periodic interrupt source in the TimerInt bean? A project demonstrating your problem would be the best.

best regards
Vojtech Filip
Processor Expert Support Team
UNIS
0 Kudos
808 Views
Telepath
Contributor I
Hello and thanks for the quick reply!

I'm not at liberty to give out the exact code, however:

Processor Expert Version 0398
Processor: [MC9S12A128_80:Cpu]

Internal bus clock: 4MHz
Clock frequency: 4MHz

PLL Clock is enabled. PLL Clock frequency is 8MHz. (Divide and Multi are both 4.)

Interrupt source is RTIfree. Interrupt period is 256us which is high speed mode, both low and slow speed mode disabled.

The code opening and closing the engine valves is all written in OnInterrupt()

I would prefer to change clock frequency as little as possible or I might have to rewrite the code for the LCD display due to needed wait states.

Is this enough information?

Kindly, Thomas
0 Kudos
809 Views
ProcessorExpert
Senior Contributor III
I think there are two options how to set exactly 250us period of the interrupt:

1)
To switch to other periodic interrupt source (e.g  TC0-TC7 or ModulusComp).

2)
To use different value of external clock source instead of 4 MHz (e.g 12.288 MHz). The reason is
the RTIfree (periodic source interrupt) device is directly connected to the oscillator and RTIfree device offers only prescalers as multiple of 1024 therefore the value of external clock source must be a multiple of 1.024 MHz. For closer look please go the the "Clock Path" tab in the Timing dialog window of the TimerInt bean.

The list of all possible values of external source for this case is attached. The red values should be possible easily to buy.

0 Kudos
808 Views
Telepath
Contributor I
Thanks a lot for these pointers, it's been very helpful.

Kindly, Thomas
0 Kudos
808 Views
Evgenij
Contributor III

Hello.

Have a problem with simulation of real-time interrupt (RTI) of mc68hc912bc32. Can you help me?

Problem is that when I simulate C program in Code Warrior True Simulation and RTI procedure called my program get to a cycle and never return to main procedure – all time doing RTI procedure (but other interrupts work!). It seems like when RTI call return vector rewrites to RTI procedure but not to last operation of main procedure. What it can be? May be I don’t include some header file, or something wrong with settings of RTI. Give me advice, please.

Excuse me for my English (if something wrong :smileyhappy:) – I’m from Ukraine.

I use Code Warrior for hc12 ver. 5.5 (without Processor Expert).

If you need I give here little demonstration project, that also has such problem.

Thank you.

0 Kudos
808 Views
CrasyCat
Specialist III
Hello
 
Did you clear the RTI interrupt in the interrupt function?
 
RTIF bit must be cleared before you return from RTI interrupt function.
 
CrasyCat
0 Kudos
808 Views
Evgenij
Contributor III
Hello.
Thank you for reply. I've already solved this problem - I was inattentive and tried to clear interrupt with RTIF = 0. :smileyvery-happy:. Reading manuall once more help me.
 
But today I got new problem - for correct writing code to my controller I need to put interrupt address vectors at other place in the memory (0xf7c0 - 0xf7ff instead of 0xffc0 - 0xffff), because memory in addresses from 0xf800 to 0xffff is protected and consists "bootloader" (I use evaluation board now). So memory for code minimized to 0x8000 - 0xf7ff (30 K) from 0x8000 - 0xffff (32 K).
 
So, question is:
Can I specify interrupt vectors to other addresses in my C codewarrior project? Now I rewrite some addresses in s19 file by hands (for them I know checksumm from examples), by it isn't very pleasure to get checksumms. :smileywink:
PS: I don't use interrupt map but standart define of interrupts (interrupt 7 void ...). Also I don't use Processor Expert and my CW ver. is 5.5, MC - mc68hc912bc32.
0 Kudos
808 Views
CrasyCat
Specialist III
Hello
 
First question here is how did you define/initialize the vector table in your application?
 
CrasyCat
0 Kudos
808 Views
Evgenij
Contributor III
Hello,
I don't define vector table as shown in different examples.
(
typedef void (*near tIsrFunc)(void);
const tIsrFunc _vect[] @0xFF80 = {     /* Interrupt table */
        UnimplementedISR,                 /* vector 63 */
        UnimplementedISR,                 /* vector 62 */
        UnimplementedISR,                 /* vector 61 */
        UnimplementedISR,                 /* vector 60 */
        UnimplementedISR,                 /* vector 59 */
.............
)
I initialize interrupt procedures as in Keil:
(
interrupt 7 void Int_RTI() {  //real-time interrupt
 uchar c;
 c_rti ++;
.................
)
And it works. The interrupts vectors I watch at memory in simulation are true.  So I think that interrupt vectors addresses define already in some lib or CW settings.
But I'll try to create interrupt map, as shown in examples.
This problem isn't critical. I'll solve it.
 
But tommorow evening I was very confused that when I burn my programs to controller (with .s19 file) it don't work correctly! E.g. it works but not that I need. In place of blinking LED it turn on the LED, in place of ansver me by terminal (when I push some key on keyboard must return simbol: 1 -> return '1') it ansvers by some other simbol.
I check COM settings of my computer and controller, replace interrupt vectors in s19 file to right (to 0xf7c0 from 0xffc0), count right checksumms. Also I notice that when I generate S0 string (head of S19) and without it my controller works different. But S0 must not burn to controller!
I've done all as in evalution board manual write but where was no effect. Burner says "Programmed", but realy program do something other.
I use single memory space, as I read s19 used as bunked but I think it isn't principial.
I don't know what to do now. Today evening I'll try to burn by other programm.
Have you any minds about this? Thanks.
0 Kudos
808 Views
CrasyCat
Specialist III
Hello
 
The notation interrupt <VectorNumber> void IntFunc(void) only works when the vector table is located at the default position (0xFF80 ).
 
If you wish  to place the table at another address you need to define your vector table through a table of constant function pointer as follows:
typedef void (*near tIsrFunc)(void);
const tIsrFunc _vect[] @0xf7c0 = {     /* Interrupt table */
        UnimplementedISR,                 /* vector 63 */
        UnimplementedISR,                 /* vector 62 */
        UnimplementedISR,                 /* vector 61 */
        UnimplementedISR,                 /* vector 60 */
        UnimplementedISR,                 /* vector 59 */
.............
)
 
Alternatively you can setup the vector table in the .prm file using command VECTOR ADDRESS.
 
For Example
  VECTOR ADDRESS 0x7FC0 UnimplementedISR
In both cases you need to remove the vector number in the interrupt definition.
Replace
   interrupt 7 void Int_RTI()
by
  interrupt  void Int_RTI()
 
Around your application burning issue I would recommend to first adjust the project to get the vector table right and then make another try.
There might be an issue in the manual operation you are conducting on your S record file.
 
CrasyCat
0 Kudos
808 Views
Evgenij
Contributor III
Hello.
I've done interrupt vectors map already and I got other s19 file. So I'll try to burn it some later and write results.
0 Kudos