Cypress Perform

Home > Design Support > Cypress Developer CommunityTM > Cypress Forums > PSoC® 3 > Reset a timer in one shot mode

Bookmark and Share
Cypress Developer CommunityTM
Forums | Videos | Blogs | Training | Rewards Program | Community Components



Reset a timer in one shot mode
Moderator:
RKRM

Post Reply
Follow this topic



Reset a timer in one shot mode

mtraedholm posted on 16 May 2012 12:45 AM PST
Member
4 Forum Posts

Hello

I have a one shot timer that I want to start multiple times on my demands in software. I have the following setup

For TopDesign see attach picture.

The isr code:

 Timer_1_ReadStatusRegister();
/* Set the flag variable */
toggle_flag = 1;

the main code:

CyGlobalIntEnable; /* Uncomment this line to enable global interrupts. */

isr_1_Start();
Timer_1_Start();

for(;;)
{
if(toggle_flag == 1)
{
toggle_flag = 0;
Timer_1_Start();
}
}

But it will only goes into the isr once (because it is a one shot timer). How do I get it to go into the isr multiple time? what did I do wrong?

An other thing in the datasheet for the timer it state the following but it does make complete sence to me can anyone explain?

"Note In order to be sure that One Shot mode does not start prematurely, you should use a

Trigger Mode to control the start time, or use some form of software enable mode (Software

Only or Software and Hardware)."

Martin 

 




Re: Reset a timer in one shot mode

Bob Marlowe posted on 16 May 2012 02:09 AM PST
Top Contributor
1768 Forum Posts

Timer_Start() will not reset the timer! You'll need to use the reset terminal (I used additionally a control-register and toggled a bit).

Keep in mind that the reset is NOT asynchronus, so you'll need an additional FF to sync with the input-clock.

 

Bob



Re: Reset a timer in one shot mode

mtraedholm posted on 16 May 2012 03:49 AM PST
Member
4 Forum Posts

Thx you.

Before I posted this thread I did try to use a control reg with an asynchronous reset that didt work, but that didt work. I will tried you suggestion soon.

 



Re: Reset a timer in one shot mode

Bob Marlowe posted on 16 May 2012 06:44 AM PST
Top Contributor
1768 Forum Posts

When you have any troubles with your project it is much easier for us to have a look at when you upload the complete project here.

To do so:in Developer 5.2:  Build -> Clean Project

then Zip (NOT Raw!) the complete folder and upload it here.

 

Bob



Re: Reset a timer in one shot mode

Gautam Das posted on 16 May 2012 09:44 AM PST
Cypress Employee
742 Forum Posts

Hi mtraedholm,

 

You can also try using the "Trigger Mode" as Rising edge or falling edge to trigger a shot.

After the trigger, the component will require a reset.

Look at the schematic below:

 

 

You can use the Terminal Count output of the Timer and OR it with "Low" to trigger a reset after every trigger ends. Hence, your next trigger will respond again. This will eliminate the requirement of manually resetting the Timer everytime.

To trigger, you can make a control register drive high and low (for rising or falling edge trigger). In this case, there is no necessity to use interrupt terminal, hence "Interrupt on TC" should be disabled.



Re: Reset a timer in one shot mode

Bob Marlowe posted on 17 May 2012 04:39 AM PST
Top Contributor
1768 Forum Posts
Dasq, your solution will work only for higher clock frequencies. When you set the clock to 1kHz the one-shot will not trigger.
There are two solutions: enlarge the trigger-pulse with DFF or use for the control-register "Pulse Mode" (which is not for all silicon versions available).
 
See attached project.
 
Bob


Re: Reset a timer in one shot mode

Gautam Das posted on 17 May 2012 10:01 AM PST
Cypress Employee
742 Forum Posts

Hi Bob,

 

Thanks for the suggestion.

My bad, I tested the project by using large delays (in order of ms) and it didn't mis-trigger.






ALL CONTENT AND MATERIALS ON THIS SITE ARE PROVIDED "AS IS". CYPRESS SEMICONDUCTOR AND ITS RESPECTIVE SUPPLIERS MAKE NO REPRESENTATIONS ABOUT THE SUITABILITY OF THESE MATERIALS FOR ANY PURPOSE AND DISCLAIM ALL WARRANTIES AND CONDITIONS WITH REGARD TO THESE MATERIALS, INCLUDING BUT NOT LIMITED TO, ALL IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT OF ANY THIRD PARTY INTELLECTUAL PROPERTY RIGHT. NO LICENSE, EITHER EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, IS GRANTED BY CYPRESS SEMICONDUCTOR. USE OF THE INFORMATION ON THIS SITE MAY REQUIRE A LICENSE FROM A THIRD PARTY, OR A LICENSE FROM CYPRESS SEMICONDUCTOR.

Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Terms and Conditions of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Terms and Conditions of this site. Cypress Semiconductor and its suppliers reserve the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.

Spec No: None; Sunset Owner: GRAA; Secondary Owner: RAIK; Sunset Date: 01/01/20