I do beleave something IS wrong when changing the prescaling in a TMR-setup (at least with TMR0) while program is running in HW.
In two branches of my program I use different prescaler in setup of TMR0 - COUNTING mode have one setting of prescaler for TMR0 and RPM mode has another.
When changing from one mode to the other I DISABLE the TMR, change the prescaler and resume.
In HW the changing DO NOT take place - it seems like the TMR stops or can't be started again in the "new" mode.
I can choose between the two branches with a CHANGE-OVER switch.
If I leave the switch in the position where the timer now do NOT run and cut off power and connects again - then it works fine again - until I change the switch - then I have to cut/connect power again for it to work.
I beleave a "software reset" would do the job - can this be done in Flowcode ?
Changing TRM setup "on the run"
Moderator: Benj
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: Changing TRM setup "on the run"
Its working fine for me, though I do have other interrupts going on. Try manually clearing the interrupt flag this may help.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Re: Changing TRM setup "on the run"
Please send your program to me so I can see.
You didn't comment on if it is possible to make a "software reset".
You didn't comment on if it is possible to make a "software reset".
Best regards
KSor, Denmark
KSor, Denmark
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: Changing TRM setup "on the run"
Hello Ksor,
I have attached the program.
A software reset can be done by using the following C code inside a C code icon in your program.
reset();
I have attached the program.
A software reset can be done by using the following C code inside a C code icon in your program.
reset();
- Attachments
-
- Ex7. Storage Scope.fcf
- (19.28 KiB) Downloaded 340 times
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Re: Changing TRM setup "on the run"
... and you even do no DISABLE before changing TMR-setup.
I made some changes to the structure of my main flowchart to get the reset(); to fit - and it works fine.
I then tried to delete the reset ... and now it works fine too - it's just spooky I think - but never mind, it works !
I made some changes to the structure of my main flowchart to get the reset(); to fit - and it works fine.
I then tried to delete the reset ... and now it works fine too - it's just spooky I think - but never mind, it works !
Best regards
KSor, Denmark
KSor, Denmark
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: Changing TRM setup "on the run"
The program works so that one of the switch case branches disables the timer interrupt. This is always called before switching the interrupt prescaler and re-enabling.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Re: Changing TRM setup "on the run"
Ok - I didn't notice that - but I was very keen remembering to DISABLE, change prescaler and enable again - but it still wouldn't do it !
But now when I changed a little in the structure of the main flowchar ... then it works - even WITHOUT the reset();
So that's it ... no more struckle with that program !
Have a nice week-end !
But now when I changed a little in the structure of the main flowchar ... then it works - even WITHOUT the reset();
So that's it ... no more struckle with that program !
Have a nice week-end !

Best regards
KSor, Denmark
KSor, Denmark