Hi.
I like this timer calculator Tool, but not my chip . I have tried to do some clicks at 2.5 ms and 100 ms. Both are calculated in the calculator software. But when running in the chip I get clicks at 1.25 ms and 50 ms.
Any clues ??? I am so tired now, that i for sure might see the error, without knowing it .
Thanks in advance
BRGDs
Klavs.
Timer works at double speed compared to what the calculator
Timer works at double speed compared to what the calculator
- Attachments
-
- DDB_MKII.zip
- (1.39 KiB) Downloaded 137 times
- marko.stankovic
- mikroElektronika team
- Posts: 108
- Joined: 18 Dec 2017 15:44
Re: Timer works at double speed compared to what the calcula
Hi,
Can you tell me which microcontroller and the oscillator you use?
Best regards,
Can you tell me which microcontroller and the oscillator you use?
Best regards,
Marko Stankovic.
Re: Timer works at double speed compared to what the calcula
Ups Sorry.
I use a STM32F103R8 with an external 8MHz crystal.
I use a STM32F103R8 with an external 8MHz crystal.
-
- Posts: 4
- Joined: 21 Dec 2018 10:30
Re: Timer works at double speed compared to what the calcula
Hello!, I have same problem! Any solution? LD1 on clicker 2 blink much speed than I predict.
//Timer0
//Prescaler 1:32; TMR0 Preload = 3036; Actual Interrupt Time : 1
//Place/Copy this part in declaration section
void InitTimer0(){
T0CON = 0x84;
TMR0H = 0x0B;
TMR0L = 0xDC;
GIE_bit = 1;
TMR0IE_bit = 1;
}
void Interrupt(){
if (TMR0IF_bit){
TMR0IF_bit = 0;
TMR0H = 0x0B;
TMR0L = 0xDC;
//Enter your code here
}
}
Thanks.
//Timer0
//Prescaler 1:32; TMR0 Preload = 3036; Actual Interrupt Time : 1
//Place/Copy this part in declaration section
void InitTimer0(){
T0CON = 0x84;
TMR0H = 0x0B;
TMR0L = 0xDC;
GIE_bit = 1;
TMR0IE_bit = 1;
}
void Interrupt(){
if (TMR0IF_bit){
TMR0IF_bit = 0;
TMR0H = 0x0B;
TMR0L = 0xDC;
//Enter your code here
}
}
Thanks.
- stefan.filipovic
- mikroElektronika team
- Posts: 1135
- Joined: 18 Dec 2018 10:30
Re: Timer works at double speed compared to what the calcula
Hi,
I realized from this part of the code that you use Clicker 2 for PIC18, but I'm not sure whether it's for PIC18FK or PIC18FJ, I guess that's the Clicker 2 for PIC18FJ.
I tried this with the Clicker 2 for PIC18FJ in several ways, but unfortunately, I was not able to reproduce this issue successfully.
Could you please attach a minimal project which reproduces this issue?
Kind regards,
I realized from this part of the code that you use Clicker 2 for PIC18, but I'm not sure whether it's for PIC18FK or PIC18FJ, I guess that's the Clicker 2 for PIC18FJ.
I tried this with the Clicker 2 for PIC18FJ in several ways, but unfortunately, I was not able to reproduce this issue successfully.
Could you please attach a minimal project which reproduces this issue?
Kind regards,
Stefan Filipović
-
- Posts: 4
- Joined: 21 Dec 2018 10:30
Re: Timer works at double speed compared to what the calcula
Thanks dear,
this is my project. And the proof of issue.
this is my project. And the proof of issue.
- Attachments
-
- These are my settings.
- screen.jpg (296.11 KiB) Viewed 5952 times
-
- Video that show issue.
- 20190104_184818.gif (3.04 MiB) Viewed 5952 times
-
- 0-99 Counter.rar
- Project.
- (9.77 MiB) Downloaded 124 times
- stefan.filipovic
- mikroElektronika team
- Posts: 1135
- Joined: 18 Dec 2018 10:30
Re: Timer works at double speed compared to what the calcula
Hi,
I just tested your project on my Clicker 2 for PIC18FJ, and unfortunately, it works as it should work.
Can you tell me does the LD1 and LD2 blinking separately with the 1s delay after loading the hex file which I just attached?
Kind regards
I just tested your project on my Clicker 2 for PIC18FJ, and unfortunately, it works as it should work.
Can you tell me does the LD1 and LD2 blinking separately with the 1s delay after loading the hex file which I just attached?
Kind regards
- Attachments
-
- Test.zip
- (928 Bytes) Downloaded 119 times
Stefan Filipović
-
- Posts: 4
- Joined: 21 Dec 2018 10:30
Re: Timer works at double speed compared to what the calcula
Here, the frequency..
- Attachments
-
- Oscilloscope
- 20190108_153403.jpg (3.02 MiB) Viewed 5929 times
- stefan.filipovic
- mikroElektronika team
- Posts: 1135
- Joined: 18 Dec 2018 10:30
Re: Timer works at double speed compared to what the calcula
Hi,
I just noticed that you are using the bootloader for programming.
In this case, if you use USB HID Bootloader you should use PLL in the config bits (on the top of the main function you also should put this code line PLLEN_bit = 1; ) and set MCU frequency to 48MHz, also you will need to generate Timer Interrupts for this MCU frequency.
Please find your modified project in the attachment.
Kind regards,
I just noticed that you are using the bootloader for programming.
In this case, if you use USB HID Bootloader you should use PLL in the config bits (on the top of the main function you also should put this code line PLLEN_bit = 1; ) and set MCU frequency to 48MHz, also you will need to generate Timer Interrupts for this MCU frequency.
Please find your modified project in the attachment.
Kind regards,
- Attachments
-
- 0-99 Counter.zip
- (9.97 MiB) Downloaded 121 times
Stefan Filipović
-
- Posts: 4
- Joined: 21 Dec 2018 10:30
Re: Timer works at double speed compared to what the calcula
Hi dear!
Finally, we are in the point! Now everything works! Thank you!
PLLEN_bit = 1; and Timer Calculator on 48Mhz.
This is an indirect way, but it works.
Finally, we are in the point! Now everything works! Thank you!
PLLEN_bit = 1; and Timer Calculator on 48Mhz.
This is an indirect way, but it works.
- stefan.filipovic
- mikroElektronika team
- Posts: 1135
- Joined: 18 Dec 2018 10:30
Re: Timer works at double speed compared to what the calcula
Hi,
You're welcome.
I'm glad that we managed to solve this.
Kind regards,
You're welcome.
I'm glad that we managed to solve this.
Kind regards,
Stefan Filipović