How to get interrupt every 0.5msec with VC3

A catchall for PSoC Mixed-Signal Array (microcontroller) discussions not captured by the other forums.

Moderator: ericb

How to get interrupt every 0.5msec with VC3

Postby eax on Fri Jun 16, 2006 6:43 am

I want to use VC3 interrupt to get interrupt every 0.5msec, but I don't know how to program it. Who can show me a sample or a demo project ?

Now I use timer8 to get a 0.5 msec interrupt, but I want to use VC3 interrupt to replace timer8....

Thank you...
eax
Newbie
Newbie
 
Posts: 5
Joined: Tue Jun 13, 2006 6:48 am

Postby graaja on Fri Jun 16, 2006 7:29 am

1. First you need to configure VC3 frequency as 2KHz. For this you can have a combination of VC1/VC2/VC3 dividers as 16/16/47 and select VC2 as VC3 source. This will result in a frequency of 1.994KHz and the interrupt will be every 5.01mS. You can also try other combinations, but the resultant VC3 frequency should be 2KHz.

2. In the main, you have to enable VC3 interrupt.

Code: Select all
M8C_EnableIntMask(INT_MSK0, INT_MSK0_VC3);


3. Modify boot.tpl and add an ljmp instruction to your VC3 interrupt handler. For example, if you are writing the interrupt handler in C,

Code: Select all
#pragma interrupt_handler vc3_isr
void vc3_isr(void)
{

}


In boot.tpl, in the VC3 vector

Code: Select all
ljmp _vc3_isr
User avatar
graaja
PSoC Master
PSoC Master
 
Posts: 3084
Joined: Thu Dec 18, 2003 4:35 pm
Location: India

Postby eax on Mon Jun 19, 2006 1:10 am

Thank you graaja, I have done it by your info.
eax
Newbie
Newbie
 
Posts: 5
Joined: Tue Jun 13, 2006 6:48 am

Re: How to get interrupt every 0.5msec with VC3

Postby rosaldorosa on Thu Jan 20, 2011 2:39 am

I followed Your instruction.
In disassembly VC3_ISR doesn't end with reti
Is it OK?

robert
rosaldorosa
The Big Cheese
The Big Cheese
 
Posts: 232
Joined: Sun Feb 21, 2010 10:51 pm

Re: How to get interrupt every 0.5msec with VC3

Postby slandrum on Thu Jan 20, 2011 7:38 am

I followed Your instruction.
In disassembly VC3_ISR doesn't end with reti
Is it OK?


Probably not.

You are responding to a post that is almost 5 years old.
slandrum
The Big Cheese
The Big Cheese
 
Posts: 453
Joined: Fri Feb 29, 2008 11:38 am
Location: California

Re: How to get interrupt every 0.5msec with VC3

Postby toalan2001 on Thu Jan 20, 2011 2:09 pm

you can save a digital block by using the watchdog timer, I think you can set it to around 1/2 a second. If 1/2hz is not avaialble you can just set it a higher rate and count the number of times the interrupt triggers to add up to 1/2 sec.
toalan2001
The Big Cheese
The Big Cheese
 
Posts: 334
Joined: Thu May 24, 2007 7:01 am

Re: How to get interrupt every 0.5msec with VC3

Postby slandrum on Thu Jan 20, 2011 2:43 pm

?

@toalan2001:
.5msec is not 1/2 sec, and every .5 sec is not .5 Hz - that would be 2Hz.

.5msec would be 2KHz.

The internal 32K clock is a very imprecise clock, with a range of -50% to +100% of the expected frequency.

@rosaldorosa:
If the correct compiler directives are used when creating an interrupt handler, then the interrupt handler should end with a "reti" instruction, not a "ret" instruction. The default compiler used with PSoC has changed more than once, so you should use the documentation you have with your current compiler for the correct way to implement interrupt handlers, and not rely in information in 5 year old posts that may or may not be consistent with your current development environment.

And when you say you "followed your instructions", whose instructions did you follow? What exactly did you do? Describe what you actually did and what happened.
slandrum
The Big Cheese
The Big Cheese
 
Posts: 453
Joined: Fri Feb 29, 2008 11:38 am
Location: California

Re: How to get interrupt every 0.5msec with VC3

Postby graaja on Thu Jan 20, 2011 5:13 pm

rosaldorosa wrote:I followed Your instruction.
In disassembly VC3_ISR doesn't end with reti
Is it OK?

robert


Did you use the "#pragma interrupt_handler" directive? If you use this directive, the compiler will terminate the ISR with reti.
User avatar
graaja
PSoC Master
PSoC Master
 
Posts: 3084
Joined: Thu Dec 18, 2003 4:35 pm
Location: India

Re: How to get interrupt every 0.5msec with VC3

Postby danadak on Fri Jan 21, 2011 2:21 am

Note you can also use the sleep timer as a long duration timer,
while NOT affecting CPU sleep operations.

http://www.cypress.com/?rID=2707

Regards, Dana.
Field Application Engineer
KB1RHB Mostly listen :)
Semi Retired
User avatar
danadak
The Big Cheese
The Big Cheese
 
Posts: 1997
Joined: Thu Dec 27, 2007 8:42 am
Location: New Hampshire

Re: How to get interrupt every 0.5msec with VC3

Postby alager on Mon Jan 31, 2011 9:30 am

One word of caution on this, is that the sleep timer has very loose specs. That appnote says 20%, but if I remember the datasheet for the 27443 it's -50%/+100%
None of this is an issue for a one off, since it doesn't appear to drift so much as it varies from chip to chip.

Aaron
User avatar
alager
The Big Cheese
The Big Cheese
 
Posts: 506
Joined: Tue Mar 15, 2005 2:26 pm
Location: Peteluma, CA

Re: How to get interrupt every 0.5msec with VC3

Postby jannypan on Wed Feb 16, 2011 5:59 pm

The default compiler used with PSoC has changed more than once, so you should use the documentation you have with your current compiler for the correct way to implement interrupt handlers, and not rely in information in 5 year old posts that may or may not be consistent with your current development environment.
jannypan
Newbie
Newbie
 
Posts: 7
Joined: Wed Feb 16, 2011 5:55 pm


Return to PSoC1 General

Who is online

Users browsing this forum: Google [Bot] and 2 guests