HCS08 Timer Question

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

HCS08 Timer Question

2,127 Views
RChapman
Contributor I
This message contains an entire topic ported from a separate forum. The original message and all replies are in this single message. We have seeded this new forum with selected information that we expect will be of value to you as you search for answers to your questions.
 
Posted: Thu Dec 01, 2005 6:15 am    
 
I have a SCI receive routine that receives characters through interrupt. I would like to be able to enable an error condition if the next character is not received within 1 second.
I am new to HCS08. However, on other micros, I would use a free running timer with an overflow interrupt. I would reset the timer every time I get a character, and if I got on overflow, I know that the next character did not receive on time.
Using the processor expert, I see that there are free-running timers but they don't generate an overflow interrupt.
I can probably do it using a free timer and an event timer but I thought I would ask the experts here about the best way of doing this.
I would appreciate anyone pointing me to the right direction.
 
Posted: Thu Dec 01, 2005 6:33 am    
 
Almost all the applications I do require some form of a "heart-beat" interrupt. Most of the HC(S) variants have some form of real-time interrupt hardware on board.
Enable that at a reasonable rate (I usually try for something around 1.0 mSec). Inside that irq I use a flag (RIP -- receive-in-progress) and counter. The first serial receive irq sets the flag and initializes the counter; every receive thereafter re-inits the counter. When the final char in the string is received the receive irq clears the RIP flag.
Meanwhile, if the heart-beat irq sees the RIP flag set it decrements the counter. If the counter ever reaches 0 an error routine is launched.
Works for me.
Posted: Thu Dec 01, 2005 6:40 am    
 
Thanks. This was very helpful. I'll give it a try.
 
Posted: Fri Dec 02, 2005 3:07 pm    
 
Why do you not use the EBS08 (you find it in the cookbook) where you can use different timing flags (i.e. from 1ms to 256ms) for your application? You can also handle all the tasks with the simple task manager (well suited for low speed communications with time outs!).

Saluti

Posted: Fri Dec 02, 2005 5:57 pm  

Sorry, I am not familiar with EBS08 and not sure which cookbook you are referring to. Can you please elaborate.
Coming from other microcontrollers, I am baffled that there is not an overflow interrupt on a free-running timer. Not having this, doubles the amout of code you have to write to acheive the same thing.

For instance on AVR you can set the value of the free-running timer to anything between 0 and 254. You always get an interrupt when the value goes to 255. So you don't have to set your own counter, check in code, etc. It is also more efficient because you don't get any interim interrupts.

I have a hard time beleiving that something as simple as that is not available on the HC08.

Posted: Sat Dec 03, 2005 1:22 am    

All of the HCS08 variants that have the "real-time" counter also have an associated overflo interrupt feature. You can enable it or disable it. I still don't know which particular one you're using so I can't be more specific.

Posted: Tue Dec 06, 2005 8:55 am    

I am trying to use processor expert as I am still new to HCS08. In the Bean selector, I pick the FreeCnt8 and set the resolution. The bean inspector tells me that the name of the interrupt is Vtpm1ovf. However, the bean inspector does not give me an event for this interrupt. If I try to generate a new interrupt vector using the InterruptVector from the Bean Selector and picking the Vtpm1ovf, it gives me an error message indicating that vector is shared.
All I want to go to this interrupt overflow routine and add my code. I don't see this on the code generated by the ProcesorExpert and I dont' know where and how I should add this myself.
I hope you can help.

Posted: Tue Dec 06, 2005 2:58 pm 

I must apologize, I cannot help you with "processor expert". I'm philosophically(?) opposed to letting someone I don't know configure my hardware or write snippets of code for me, so I don't use things like that.
Sorry.

Posted: Tue Dec 06, 2005 9:15 pm    

Try ProcessorExpert's bean TimerInt. It provides OnInterrupt event called after selected time period.

Labels (1)
0 Kudos
0 Replies