Hello,
I am attempting to Reset a Timer when going thru a Interrupt routine.
The logic i am using seems to be correct as i can stop the counter, change a bit flag and such, but the counter just does not reset. I am hoping someone in this group can tell me what i might be doing incorrectly.
I am really new to actually using flowcode, am not a programmer, but trying to learn.
Also, need to get the most accurate count that i can, so if there is any other method. I would like to be in the nanosecond range.
I am building an ultrasonic guiding system using a TDC1000 chip. The chip is doing all the needed upfront work I am just needing to pickup the time interval between a start pulse and a stop pulse. The transmitting signal is going to be 2 inches away from the receiving transducer, so there is not much time to spare between pulses.
For Proto-typing, i am using a BL00032-1 DSP, a bl069-1 LCD display on portB Low port and a BL0145 PB used to simulate an interrupt port. The PB port will be replaced with the TDC1000 chip start stop signal when that board gets completed.
COMPONENT MACRO RESET TIMER
-
- Posts: 8
- http://meble-kuchenne.info.pl
- Joined: Sat Dec 19, 2020 11:53 pm
-
- Matrix Staff
- Posts: 1895
- Joined: Mon Dec 07, 2020 10:06 am
- Has thanked: 491 times
- Been thanked: 664 times
Re: COMPONENT MACRO RESET TIMER
Hello,
Looking at your program there shouldn't be a need to disable and re-enable the INT0 interrupt in the StartCountStatus macro. This could potentially be causing problems.
In your main you might want to print out a string of spaces " " after printing your number and this way it will ensure the end of your string doesn't get visibly corrupted by a previous value.
Other then that I think it looks ok.
Looking at your program there shouldn't be a need to disable and re-enable the INT0 interrupt in the StartCountStatus macro. This could potentially be causing problems.
In your main you might want to print out a string of spaces " " after printing your number and this way it will ensure the end of your string doesn't get visibly corrupted by a previous value.
Other then that I think it looks ok.
Regards Ben Rowland - MatrixTSL
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
Re: COMPONENT MACRO RESET TIMER
Hi Ben,
Thank you for your last reply.
I have changed the code numerous ways in attempting to reset the counter with out having success.
I do see that the debug values and the actual compiled code displays with different results. on the simulation i am not updating the value, yet in the compiled version i am getting some type of a number.
Could you please take another look please? The counter just does not seem to be resetting back to zero. Even in the simulation the 2d component for the timer is showing that it does not reset.
Kind Regards,
Karl Gross
Thank you for your last reply.
I have changed the code numerous ways in attempting to reset the counter with out having success.
I do see that the debug values and the actual compiled code displays with different results. on the simulation i am not updating the value, yet in the compiled version i am getting some type of a number.
Could you please take another look please? The counter just does not seem to be resetting back to zero. Even in the simulation the 2d component for the timer is showing that it does not reset.
Kind Regards,
Karl Gross
- Attachments
-
- Usensor1-0.fcfx
- (20.39 KiB) Downloaded 223 times
-
- Valued Contributor
- Posts: 1213
- Joined: Wed Dec 09, 2020 9:37 pm
- Has thanked: 118 times
- Been thanked: 622 times
Re: COMPONENT MACRO RESET TIMER
Something is going wrong with the PrintNumber - which will only show a 16 bit value.
I did a few things.
1) I removed the ResetTimer and Added 'true' to the StartTimer to reset it.
2) I added an .x = GetRawCount into the loop in main (to check the value was actually changing)
3) Then - I added a conversion of TimePassed to a string and printed that instead of using PrintNumber.
This seems to work - at least in simulation.
I'm not sure why PrintNumber is always showing 0 - however - as this is what it does 'behind the scenes' (albeit for signed 16 bit values)
Your loop in main is currently redrawing the display very frequently (every time through the loop) - I would change this to only redisplay the numeric values if they have changed. This shouldn't affect the simulation - but it is shifting a lot of data to the display on the hardware.
Martin
I did a few things.
1) I removed the ResetTimer and Added 'true' to the StartTimer to reset it.
2) I added an .x = GetRawCount into the loop in main (to check the value was actually changing)
3) Then - I added a conversion of TimePassed to a string and printed that instead of using PrintNumber.
This seems to work - at least in simulation.
I'm not sure why PrintNumber is always showing 0 - however - as this is what it does 'behind the scenes' (albeit for signed 16 bit values)
Your loop in main is currently redrawing the display very frequently (every time through the loop) - I would change this to only redisplay the numeric values if they have changed. This shouldn't affect the simulation - but it is shifting a lot of data to the display on the hardware.
Martin