timer interrupt overflow bug

General discussion on mikroPascal PRO for AVR.
Post Reply
Author
Message
nevoMV
Posts: 7
Joined: 08 Mar 2012 08:19

timer interrupt overflow bug

#1 Post by nevoMV » 10 Apr 2014 10:13

Hi erverbody,

I'm using a micromedia for xmega board with the newes mikroPascal PRO for AVR v6.0.0.
I need a LED toggling at 30Hz. For this I use a timer overflow interrupt. See below.
But unfortunately sometimes the ISR seems to be used in a very close time distance. It toggles 2 times for less then 1us . See attached picture file.
It would be great if somebody has an idea for me.
(I tried different clocktypes, no watchdog is running)

Code: Select all

TCC0_PERL := 0x8D;
TCC0_PERH := 0x20;
TCC0_CTRLA := 0x05;
TCC0_INTCTRLA := 0x02;
PMIC_CTRL := 0x02;
CPU_SREG.B7 := 1;

Code: Select all

procedure TimerTCC0Overflow_ISR(); org IVT_ADDR_TCC0_OVF;
begin
  PORTC_OUTTGL := %00000001;
end;
Init

Code: Select all

RC32MEN_bit :=1;        // 32MHz internal RC oscillator   
while(RC32MRDY_bit = 0) do
;
CPU_CCP := 0xD8;
CLK_CTRL := 1;     

CLK_PSCTRL:=0;                        // Vorteiler auf keine Teilung setzen
PMIC_CTRL := 0x07;                    // Enable medium level interrupts
CPU_SREG.B7 := 1;                     // Global Interrupt enable

InitializeTouchPanel();
UARTC0_init(9600);
SPIC_Init_Advanced(_SPI_MASTER,_SPI_FCY_DIV128, _SPI_CLK_LO_LEADING);       // SPI Port init
    Delay_ms(10);
    // Initialize MMC
    // UART_byte(Mmc_Fat_Init());                                                  // Ausgabe UART MMC-Status bit
    if (Mmc_Fat_Init() = 0) then
       begin
            // Reinitialize SPI at higher speed
            SPIC_Init_Advanced(_SPI_MASTER,_SPI_FCY_DIV4, _SPI_CLK_LO_LEADING);
            flag_sd_vorhanden := 1;
            UARTC0_WRITE_text('SD INIT');UARTC0_WRITE(10);UARTC0_WRITE(13);
         end
    else
        Begin
            flag_sd_vorhanden := 0;
            UARTC0_WRITE_text('No SD');UARTC0_WRITE(10);UARTC0_WRITE(13);

        end;
Attachments
timeroverflow.jpg
timeroverflow.jpg (250.19 KiB) Viewed 1460 times
------------------------------------------------------------
Vorbeugen ist besser als auf die Schuhe kotzen! :roll:

Post Reply

Return to “mikroPascal PRO for AVR General”