Z-Uno2 GPT problems

Discussion about Z-Uno product. Visit http://z-uno.z-wave.me for more details.
Post Reply
GregN
Posts: 35
Joined: 20 Aug 2015 01:47

Z-Uno2 GPT problems

Post by GregN »

When using the GPT (in beta version 3.0.12) is seems as though once the timer is disabled with a zunoGPTEnable(0) it can never be re-enabled. So, in the following sketch (the General Purpose Timer example sketch), if the zunoGPTEnable(0) is uncommented then the interrupt handler is never called:

Code: Select all

ZUNO_SETUP_ISR_GPTIMER(gpt_handler);

unsigned long count_gpt = 0;

void gpt_handler() {
    count_gpt++;
}

void setup() {
    zunoGPTInit(ZUNO_GPT_SCALE1024|ZUNO_GPT_CYCLIC);
    zunoGPTSet(65);
    zunoGPTEnable(1); 

    // zunoGPTEnable(0); 

    zunoGPTInit(ZUNO_GPT_SCALE1024|ZUNO_GPT_CYCLIC); // just in case these have to be ...
    zunoGPTSet(65);                                  // re-initialised after disabling GPT
    zunoGPTEnable(1); 

    Serial.begin(115200);
}

void loop() {
    Serial.println(count_gpt);
    delay(1000);
}
Also, the absence of the ZUNO_GPT_IMWRITE flag doesn't seem to affect zunoGPTSet() as I would expect. Although the documentation isn't clear I assume that without that flag being set there should be an effective queue of one timer value, so that when the timer is counting down to zero and zunoGPTSet(n) is called with a new value then when the GPT does reach zero then that new value will immediately be used for the next count, but this doesn't seem to happen.
amatilda
Posts: 68
Joined: 26 Sep 2021 22:09

Re: Z-Uno2 GPT problems

Post by amatilda »

GregN wrote:
15 Jul 2024 16:15
When using the GPT (in beta version 3.0.12) is seems as though once the timer is disabled with a zunoGPTEnable(0) it can never be re-enabled. So, in the following sketch (the General Purpose Timer example sketch), if the zunoGPTEnable(0) is uncommented then the interrupt handler is never

Also, the absence of the ZUNO_GPT_IMWRITE flag doesn't seem to affect zunoGPTSet() as I would expect. Although the documentation isn't clear I assume that without that flag being set there should be an effective queue of one timer value, so that when the timer is counting down to zero and zunoGPTSet(n) is called with a new value then when the GPT does reach zero then that new value will immediately be used for the next count, but this doesn't seem to happen.
Hello.
Yes, there are two such problems.
To fix it right away, you can download https://github.com/Z-Wave-Me/Z-Uno-G2-C ... oseTimer.c and replace the corresponding local file.
GregN
Posts: 35
Joined: 20 Aug 2015 01:47

Re: Z-Uno2 GPT problems

Post by GregN »

Hi amatilda,

Thanks.
niky94547
Posts: 23
Joined: 31 May 2019 10:51

Re: Z-Uno2 GPT problems

Post by niky94547 »

Hello,

I would like to ask, if there is an option to enable GPT from external ISR handler. In Old Zuno GEN5, I've been using zunoGPTEnable(1), within ext interrupt handler function and timer started, there were no issues observed. Here in Zuno GEN7 timer not starting, if used within external interrupt handler. As I need precise timing, just direct flag and the execution in the loop is not a good option. Also I could timestamp micros within external ISR and then have tight limits within loop, in order to execute exactly on same timing after external interrupt event occur (external interrupt is a constant
repetitive). Which yes not and elegant solution and prolong final execution.

Is there any safe way to enable timer within external ISR context, or any other approach to test :)

Thanks,

Best Regards,
Post Reply