Timer0, 1, 2, INT0, INT1, Analog Comparator

Post your requests and ideas on the future development of mikroPascal PRO for AVR.
Author
Message
RCR
Posts: 3
Joined: 31 Dec 2008 00:49

Timer0, 1, 2, INT0, INT1, Analog Comparator

#1 Post by RCR » 31 Dec 2008 00:58

Hello, i use atmega8 in many application, and i see that in libraryes is only PWM1 that work for timer2, but why isn't a PWM16 library for Timer1, to use the other two PWM channels (OC1A,OC1B)?

I see that isn't any library for the timers and interrupts, analog comparator, watchdog, or power modes. It's only a suggestion :) because other programming tools have thes things..

I want to know if in the future it is possible to make this libraryes, or i should make it my self.

corado
Posts: 399
Joined: 28 Mar 2009 11:03

#2 Post by corado » 11 Oct 2009 14:11

I need this Funktion too

User avatar
anikolic
mikroElektronika team
Posts: 1775
Joined: 17 Aug 2009 16:51
Location: Belgrade
Contact:

#3 Post by anikolic » 19 Oct 2009 09:37

Hi,
This issue has been resolved in the upcoming release of mikroPascal PRO for AVR. It will be soon available for beta testing, so you can try giving us more suggestions in the beta-testing period, so we can improve our compilers even more.

Thank you for your support!

Best regards,
Aleksandar
Web Department Manager

pykedgew
Posts: 164
Joined: 10 Dec 2005 02:22
Location: Brisbane Australia

Re:

#4 Post by pykedgew » 28 Aug 2010 00:56

Hi to the mikroTeam
aleksandar.nikolic wrote:Hi,
This issue has been resolved in the upcoming release of mikroPascal PRO for AVR. It will be soon available for beta testing, so you can try giving us more suggestions in the beta-testing period, so we can improve our compilers even more.

Thank you for your support!

Best regards,
Aleksandar
Oct 19, 2009
I am wondering has any of these functions below has been implemented as requested by RCR?

Code: Select all

Functions                In Library
Timers                 : None (example in assembler code)
Interrupts             : Yes
Analog Comparator      : None
Watchdog               : None
Power Modes            : ????  I presume he talking about sleep/wake up mode
Timer0, Timer1, Timer2 : None
Int0, Int1             : None
Reason why, now I want to use the "Analog Comparator" AIN0 AIN1 & nowhere I can find them.
Chip I want to use with is ATtiny13, ATtiny26 & ATmega8 at the moment.

So I was under the impression these were to be made available in the recent release but appears to not be.
Or have I overlook where they hiding & don't know where to look?
Please do not tell me I have to write my own library or code to do this.

Awaiting for further comment.

Ken

User avatar
anikolic
mikroElektronika team
Posts: 1775
Joined: 17 Aug 2009 16:51
Location: Belgrade
Contact:

Re: Timer0, 1, 2, INT0, INT1, Analog Comparator

#5 Post by anikolic » 01 Sep 2010 12:15

Hello pykedgew,

1. PWM16 library is available in AVR compilers for a long time. Please take a look at mikroPascal PRO for AVR v3.20beta Help file for more information about this library. If you have any other enhancement suggestions, please explain them briefly, and I will inform our developers.

2. Timer0, Timer1, Timer2 and Interrupts: I am not quite sure what you mean by this, but you can now use timer overflow interrupts even more easier, since we have introduced iv linker directive and we have inserted all timer vectors in definition files. Here's the example of using Timer0 interrupt:

Code: Select all

procedure Timer0Overflow_ISR(); iv IVT_ADDR_TIMER0_OVF;
3. Analog Comparator and Power Modes: Please explain what kind of implementation do you expect, regarding these features?

4. Watchdog: We have introduced CLRDWT function that can be called from hi-level languages instead only from assembly, but generating watchdog handling routines was demonstrated in several forum posts. If you think that there should be some kind of WDT library, you may suggest so, and we I will pass this to our developers.

Best regards,
Aleksandar
Web Department Manager

aliali
Posts: 1
Joined: 17 Dec 2010 12:58

Re: Timer0, 1, 2, INT0, INT1, Analog Comparator

#6 Post by aliali » 17 Dec 2010 13:21

I very need
INT0, INT1, Analog Comparator
do you have any code for them?
please say me how to write them in compiler?

Toenne
Posts: 6
Joined: 13 Jan 2013 16:08

Re: Timer0, 1, 2, INT0, INT1, Analog Comparator

#7 Post by Toenne » 13 Jan 2013 17:26

Timer0, Timer1, Timer2 and Interrupts: I am not quite sure what you mean by this, but you can now use timer overflow interrupts even more easier
...but still far and away from Bascom ;).
What's the sense of pascal if you still have to push bits and bytes like in C or in ASM?
In Bascom you CAN access registers directly but you don't HAVE TO :).
So it would really be great if you would integrate a more comfortable solution.

Until now I was programming my avr with bascom, but because I'm using Delphi for my Windows applications I'm testing MikropascalAVR. This limitation doesn't make the decision against bascom easier, at the moment I really don't know whether I should buy a licence or not... :?

Best regards
Toenne

corado
Posts: 399
Joined: 28 Mar 2009 11:03

Re: Timer0, 1, 2, INT0, INT1, Analog Comparator

#8 Post by corado » 14 Jan 2013 10:49

I think this is an good Idea too!!
This is the reason, why I use Pascal an not gcc

User avatar
janko.kaljevic
Posts: 3565
Joined: 16 Jun 2011 13:48

Re: Timer0, 1, 2, INT0, INT1, Analog Comparator

#9 Post by janko.kaljevic » 14 Jan 2013 18:28

Hello,
Toenne wrote:
What's the sense of pascal if you still have to push bits and bytes like in C or in ASM?
In Bascom you CAN access registers directly
Please can you explain this with a line of code.

In mikroPascal you can directly access to registers.
List of all registers can be previewed in def file.

Best regards.

Toenne
Posts: 6
Joined: 13 Jan 2013 16:08

Re: Timer0, 1, 2, INT0, INT1, Analog Comparator

#10 Post by Toenne » 14 Jan 2013 19:23

See attachment, it's from the bascom help file (*).

Example: I want to use timer1 in normal mode to toggle a led every second (at 16MHz).

Code: Select all

$crystal = 16000000
...
Config Timer1 = Timer , Prescale = 256
On Timer1 Timer_irq
Const Timerpreset = 18661
Enable Timer1
Enable Interrupts

...

Timer_irq:
 Toggle Led
 Timer1 = Timerpreset
Return
Really simple, isn't it? ;)
Another benefit: If I want to use the code for another type of avr (maybe because I've run out of memory so I have to use a 'bigger' one) I have to change...nothing!
All the parameters are plaintext. For example if I want to use the timer as counter I just write "Timer1 = counter". And if I want him to count on falling edges I just write "edge = falling". For all this I don't need to study the data sheet first, it's more or less self-explanatory and the same for all types. I don't have to brood about bits and bytes, I can concentrate myself for the code/solution itself.

E.g. the pwm-mode:

Code: Select all

'And the TIMER can be used in PWM mode
'You have the choice between 8,9 or 10 bit PWM mode
'Also you can specify if the counter must count UP or down after a match
'to the compare registers
'Note that there are two compare registers A and B

Config Timer1 = Pwm , Pwm = 8 , Compare A Pwm = Clear Up , Compare B Pwm = Clear Down , Prescale = 1
Nevertheless I can access the registers directly if I want so. But why should I? ;)
It's the main advantage of high-level languages that the code is easy to write and easy to read I think. And the risk for making errors is much smaller.

I've just tried to program a countdown timer with mikropascal - and the timer did whatever he wanted to, but not what I wanted. After hours of testing it works, but know what? I have no clue why it works now but not at the beginning, looks like somewhere one bit was 'jammed'...

OK, Professionals who work every day with µc don't have this problems, they have the needed routines, registers and bits in mind. But most of them will already use C or ASM I think ;).

Best regards (and sorry for my scary english :lol: )
Toenne

(*) Oops - no way to attach a pdf?

Toenne
Posts: 6
Joined: 13 Jan 2013 16:08

Re: Timer0, 1, 2, INT0, INT1, Analog Comparator

#11 Post by Toenne » 14 Jan 2013 19:31

janko.kaljevic wrote:
Toenne wrote:
In Bascom you CAN access registers directly
Please can you explain this with a line of code.
I think your main question was how to access registers directly in Bascom? ;)
TCCR2A=&b10100000
The names of registers (TCCR1A, ICR1H, TCNT0...) are reserved words, if you use them the complier translates them into the correct adress for the avr defined at top of program (e.g. $regfile = "m8def.dat").

Best regards,
Toenne

User avatar
janko.kaljevic
Posts: 3565
Joined: 16 Jun 2011 13:48

Re: Timer0, 1, 2, INT0, INT1, Analog Comparator

#12 Post by janko.kaljevic » 15 Jan 2013 15:33

Hello,

It is good idea, and it is easier to set hardware modules this way.

And it is our goal to make programming easier with every release and to add more tools and modules which will allow faster and easier programming.
Also for us it is important suggestions like these, because we can listen what is important to our users.

Thanks for suggestion and supporting.
Also thanks for the effort that you invested in order to properly describe this matter.

Best regards.

kcbob
Posts: 13
Joined: 10 Apr 2012 03:14

Re: Timer0, 1, 2, INT0, INT1, Analog Comparator

#13 Post by kcbob » 17 Jan 2013 02:48

Example: I want to use timer1 in normal mode to toggle a led every second (at 16MHz).

Code: Select all
$crystal = 16000000
...
Config Timer1 = Timer , Prescale = 256
On Timer1 Timer_irq
Const Timerpreset = 18661
Enable Timer1
Enable Interrupts

...

Timer_irq:
Toggle Led
Timer1 = Timerpreset
Return

Really simple, isn't it? ;)
Another benefit: If I want to use the code for another type of avr (maybe because I've run out of memory so I have to use a 'bigger' one) I have to change...nothing!
You can do things like this with AVRco, another Pascal compiler for AVR--which, by the way, also has tasking built in. It's a nice development package. Very nice. But the license will cost you a fair amount more.

schol
Posts: 3
Joined: 27 Mar 2013 09:16

Re: Timer0, 1, 2, INT0, INT1, Analog Comparator

#14 Post by schol » 27 Mar 2013 09:28

For me, timers the basis of my application and their ommission is a major problem unless I migrate to pics.
So, please lets have counter timer functions

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: Timer0, 1, 2, INT0, INT1, Analog Comparator

#15 Post by filip » 27 Mar 2013 12:37

Hi,

Thank you for your suggestion.
For now, you can use Timer examples located in the Examples folder of the compiler.

Regards,
Filip.

Post Reply

Return to “mikroPascal PRO for AVR Wish List”