Timer Calculator Application Released!

Timer Calculator is a free software development tool used for easier calculation of timer interrupts.
Author
Message
ISL_Dave
Posts: 695
Joined: 29 Jul 2009 09:48
Location: Sheffield

Re: Timer Calculator Application Released!

#76 Post by ISL_Dave » 10 Oct 2014 14:52

Hi Mark,

I think you may find it useful to look at this thread: http://www.mikroe.com/forum/viewtopic.php?f=194&t=61866

I have just posted a little tool that will forcibly move applications to a specific x:y co-ordinate.

I would not be able to function without this since it is impossible in Windows 7 to move a fixed size window if you cannot access the top line to drag it. It was easy to do in all previous versions of windows, including Vista by using the shift + cursors or right clicking on the taskbar and selecting to move and then using the cursors.

That's progress for you.

I do also have a query about the Timer Calculator. It does not appear to generate the proper code for PIC24 devices.

1. It sets an interrupt priority bit for Timer1 when I am generating Timer2 code. Here is the code it generated

Code: Select all

//Timer2
//Prescaler 1:8; PR2 Preload = 10000; Actual Interrupt Time = 5 ms
 
//Place/Copy this part in declaration section
void InitTimer2(){
  T2CON	 = 0x8010;
  T2IE_bit	 = 1;
  T2IF_bit	 = 0;
  IPC0		 = IPC0 | 0x1000;
  PR2		 = 10000;
}
 
void Timer2Interrupt() iv IVT_ADDR_T2INTERRUPT{
  T2IF_bit	 = 0;
  //Enter your code here 
}
It is IPC1 that contains the interrupt priority level for Timer2, IPC0 contains the interrupt priority level for Timer1!

I just need to find out why the timer seems to be out by 50%. :x

Before it is said, I have selected the correct 32MHz clock frequency. :lol:

[EDIT]I have tried to use the application to set a 1s timer using timer1 but I get a 0.5ms timer (again, the project compiles and works at 32MHz, library delay_ms(1000) provides a 1s delay and my UART comms work so this also proves the micro clock is running at 32MHz).
Timer1.jpg
Timer1.jpg (94.93 KiB) Viewed 72068 times
It is allowing for the timer clock on the P24 running at Fosc/2 rather than the Fosc/4 that the P18 devices use isn't it? :roll:

I have to set the MCU clock frequency (IN TIMER CALCULATOR APPLICATION) to 64MHz to get the correct values.

pappicio
Posts: 3
Joined: 14 Apr 2015 21:11

Re: Timer Calculator Application Released!

#77 Post by pappicio » 17 Apr 2015 18:34

I have a question:
this is my code by pic timer calculator:

Code: Select all

Timer0
'Prescaler 1:8; TMR0 Preload = 6; Actual Interrupt Time : 1 ms
 
'Place/Copy this part in declaration section
sub procedure InitTimer0()
  OPTION_REG	 = 0x82
  TMR0		 = 6
  INTCON	 = 0xA0
end sub
 
sub procedure Interrupt()
  if (TMR0IF_bit) then
    TMR0IF_bit	 = 0
    TMR0		 = 6
    'Enter your code here
  end if
end sub

so, every 4 us, timer0 increase by 1 value, now, when it arrives to 255, sets tmr0_bit to 1, and jump to interrupt; and execute:
if (TMR0IF_bit) then
TMR0IF_bit = 0
TMR0 = 6

all theese instructions take cicles, now, my question is:
to have exactly 1ms, the calculation have to considerate also all theese instructions, and exactly:
with 16F pic, and 8 Mhz crystal and PRESCALER 1:8, in debug we have:
2 cycles=1 us and 4 us increase by 1 the TMR0 counter, soevery 8 cycles, TMR0 increases.
so, when TMR0' s counter reaches 255, it appen:
TMR0IF_bit = 1 (automatically when counter reach 255)= 2 cycles
+
(jump to interrupt); 11 cycles (or maybe 11 cycles are to set TMR0IF_bit to 1 and jump to interrupt?)
+
if (TMR0IF_bit) then; 2 cycles
+
TMR0IF_bit = 0; 2 cycles
+
TMR0 = 6; 2 cycles
= 19 cycles,
(every 8 cycles TMR0 increases)
19/8=2.3
theTMR0 counter increases itself by 2.3, only jumping to interrupt routine; resetting TMR0IF_bit to 0 and setting TMR0 to 6, in my opinion, the value of TMR0 in interrupt routine should be 6+2.3=8.3; 8 rounding it.
I' m wrong?
thanks in advances to everyone wants to check all I written and correct if I'm wrong.

MARIO
Posts: 978
Joined: 18 Aug 2008 22:13
Location: Brasil

Re: Timer Calculator Application Released!

#78 Post by MARIO » 28 May 2015 00:44

I wish to suggest a little improvement,

What about to memorize the last microcontroller used?

Because every time one needs to look for the uC.

Thanks.
BR
EasyPic6 and registered mkC PRO FOR PIC since 2011
You're never too old to learn something stupid.(PARAPROSDOKIAN)

User avatar
Aleksandar.Mitrovic
mikroElektronika team
Posts: 1697
Joined: 11 Mar 2015 12:48

Re: Timer Calculator Application Released!

#79 Post by Aleksandar.Mitrovic » 28 May 2015 14:06

Hi Mario,

Do you refer to the Timer Calculator application? You can save your project settings on some preset.

Just generate code and press "Save" button, code will be saved on selected preset.

Best regards,
Aleksandar

MARIO
Posts: 978
Joined: 18 Aug 2008 22:13
Location: Brasil

Re: Timer Calculator Application Released!

#80 Post by MARIO » 28 May 2015 18:14

Hi Aleksandar.

Yes, I'm talking about Timer Calculator.

I'm talking about to save the data fields on the left side.
So it's easier to modify (at least in my opinion) what you want directly, without to pick one on the presets list.

I mean, to memorize the last used configuration, for example, PIC18.
So every time I open the TC, it automatically loads the last used configuration (uC and fields), in this case, PIC18.
Saving the preset, I will have to look for it every time and then load it.
And once you load the preset, if you wish to change the clock frequency, you have to look for another preset as the clock field becomes blocked.
So I have to choose the uC family again to unblock the clock field.

It's a little bit different.

Does it make sense?
BR
EasyPic6 and registered mkC PRO FOR PIC since 2011
You're never too old to learn something stupid.(PARAPROSDOKIAN)

User avatar
Aleksandar.Mitrovic
mikroElektronika team
Posts: 1697
Joined: 11 Mar 2015 12:48

Re: Timer Calculator Application Released!

#81 Post by Aleksandar.Mitrovic » 01 Jun 2015 10:44

Hi Mario,

Thank you for this suggestion.
I will forward this to our Development team.

I agree, this will be much easier and it will be fine addition to our Time Calculator.

Best regards,
Aleksandar

saschech
Posts: 298
Joined: 04 Sep 2012 07:13
Location: Schechingen Germany

Re: Timer Calculator Application Released!

#82 Post by saschech » 12 Jul 2016 12:38

hello
I read on libstock:
@Vadiliano
The problem lies in settings for APBx prescalers. If you set APBx prescalers different than 1, compiler->Edit Project, then you have double frequency for timer clock. This "bug" will be fixed in the next release of TC.
The next release will include support for STM32F7xx, Kinetis mcus, some bug fixed and it is scheduled for end of June.

any news about the update?

regards wolfgang

User avatar
Aleksandar.Mitrovic
mikroElektronika team
Posts: 1697
Joined: 11 Mar 2015 12:48

Re: Timer Calculator Application Released!

#83 Post by Aleksandar.Mitrovic » 13 Jul 2016 11:48

Dear wolfgang,

Update for the Timer Calculator is coming soon.
It is in the final test phase. This should be fixed, among other things, in this update.

Thank you for your patience.

Regards,
Aleksandar

Post Reply

Return to “Timer Calculator”