Use Timer or Systick

Post your requests and ideas on the future development of mikroPascal PRO for AVR.
Post Reply
Author
Message
corado
Posts: 399
Joined: 28 Mar 2009 11:03

Use Timer or Systick

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

Hallo
for calculate capacity I need a Timer Routime.

From an other Compiler I know this Funktion.

Procedure Onsystick
Begin
x:=x+1;
end;

I need a Prodcedure like this im mikropascal!

This routine is startet on every Systick (in first Line of Programm I can set ist to 10ms or more)
It uses Interrupt, that is a good thing, because It stop all other Proccesses and calculate it at the right moment....

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

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

Oh, in the Demo Folder I find something that might work:-)

Code: Select all

program Timer0_Interrupt;

const _THRESHOLD = 20;
var counter : byte;

procedure Timer0Overflow_ISR(); org IVT_ADDR_TIMER0_OVF ;
  begin
    if (counter >= _THRESHOLD) then
      begin
        PORTB := not PORTB;      // toggle PORTB
        counter := 0;            // reset counter
      end
    else
      Inc(counter);              // increment counter
  end;

begin

  DDRB   :=  0xFF;               // set PORTB as output
  PORTB  :=  0;                  // clear PORTB

  SREG_I_bit := 1;               // Interrupt enable
  TOIE0_bit  := 1;               // Timer0 overflow interrupt enable
  TCCR0  := 5;                   // Start timer with 1024 prescaler

  while TRUE do nop;             // Endless loop, port is changed inside Interrupt Service Routine (ISR)
end.

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

#3 Post by corado » 11 Oct 2009 14:29

but it is not easy enough for and noop like me:-)

Better is, if there where think like
systick=10; for 10ms ...

Post Reply

Return to “mikroPascal PRO for AVR Wish List”