Changing TRM setup "on the run"

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 4.
To post in this forum you must have a registered copy of Flowcode 4 or higher. To sign up for this forum topic please use the "Online Resources" link in the Flowcode Help Menu.

Moderator: Benj

Post Reply
ksor
Posts: 126
Joined: Mon Oct 23, 2006 3:50 pm
Contact:

Changing TRM setup "on the run"

Post by ksor »

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 ?
Best regards
KSor, Denmark

User avatar
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"

Post by Benj »

Its working fine for me, though I do have other interrupts going on. Try manually clearing the interrupt flag this may help.

ksor
Posts: 126
Joined: Mon Oct 23, 2006 3:50 pm
Contact:

Re: Changing TRM setup "on the run"

Post by ksor »

Please send your program to me so I can see.

You didn't comment on if it is possible to make a "software reset".
Best regards
KSor, Denmark

User avatar
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"

Post by Benj »

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();
Attachments
Ex7. Storage Scope.fcf
(19.28 KiB) Downloaded 314 times

ksor
Posts: 126
Joined: Mon Oct 23, 2006 3:50 pm
Contact:

Re: Changing TRM setup "on the run"

Post by ksor »

... 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 !
Best regards
KSor, Denmark

User avatar
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"

Post by Benj »

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.

ksor
Posts: 126
Joined: Mon Oct 23, 2006 3:50 pm
Contact:

Re: Changing TRM setup "on the run"

Post by ksor »

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 ! :lol:
Best regards
KSor, Denmark

Post Reply