Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem



Posted by Breno Pinheiro on February 1, 2008
Hi all, I'm tried to use the interruption from Timer2_ovf and Timer0_ovf an atmega128 but it doesn't work out. The INT0 and INT1 vector work fine. I'm posting my code so that you could figure out.

#include <stdlib.h>
#include <string.h>
#include <stdio.h>

/* EEPROM routines used only with the WinAVR compiler. */
#include <avr/eeprom.h>

/* Scheduler include files. */
#include "FreeRTOS.h"
#include "task.h"
#include "croutine.h"
#include "semphr.h"
#include <avr/interrupt.h>
#include <avr/sleep.h>
#include <../../Source/include/semphr.h>
#include <math.h>
/* Demo file headers. */

#include "PollQ.h"
#include "integer.h"
#include "serial.h"
#include "comtest.h"
#include "crflash.h"
#include "print.h"
#include "partest.h"
#include "regtest.h"

#define SIGNAL__attribute__ ((signal))

/* Baud rate used by the serial port tasks. */
#define mainCOM_TEST_BAUD_RATE( ( unsigned portLONG ) 38400 )

void TIMER0_OVF(void)__attribute__ ((signal,naked));
void vApplicationIdleHook( void );

portSHORT main( void )
/* Registers */

SREG = 0x80;
MCUCR = 0x03;
EICRA = 0x0F;
EIMSK = 0x03;
TIMSK = 0x01;
TCCR0 = 0x03;

xSerialPortInitMinimal( mainCOM_TEST_BAUD_RATE, 1 );



return 0;

ISR(TIMER0_OVF_vect) // INT_0 or INT_1 work out!!!
vParTestToggleLED( 1);

void vApplicationIdleHook( void )

Thanks, for all!!!!


Posted by woops_ on February 1, 2008
Dont know the answer but dont think it is anything todo with FreeRTOS so must just be in the register settings. Are there examples in the compiler to copy?


Posted by Jay on February 1, 2008
See my thread here https://sourceforge.net/forum/forum.php?thread_id=1882976&forum_id=382005

The default is for Timer1 not 0 or 2 (8-bit) or 3(second 16-bit timer)

If you want to change it, you need to modify the port.c file

#define portCOMPARE_MATCH_A_INTERRUPT_ENABLE( ( unsigned portCHAR ) 0x10 )
//set it to the correct interrupt mask for TIMER3 if you like

* Setup timer 1 compare match A to generate a tick interrupt.
static void prvSetupTimerInterrupt( void )
unsigned portLONG ulCompareMatch;
unsigned portCHAR ucHighByte, ucLowByte;

/* Using 16bit timer 1 to generate the tick. Correct fuses must be
selected for the configCPU_CLOCK_HZ clock. */

ulCompareMatch = configCPU_CLOCK_HZ / configTICK_RATE_HZ;

/* We only have 16 bits so have to scale to get our required tick rate. */
ulCompareMatch /= portCLOCK_PRESCALER;

/* Adjust for correct value. */
ulCompareMatch -= ( unsigned portLONG ) 1;

/* Setup compare match value for compare match A. Interrupts are disabled
before this is called so we need not worry here. */
ucLowByte = ( unsigned portCHAR ) ( ulCompareMatch & ( unsigned portLONG ) 0xff );
ulCompareMatch >>= 8;
ucHighByte = ( unsigned portCHAR ) ( ulCompareMatch & ( unsigned portLONG ) 0xff );
OCR1AH = ucHighByte;
OCR1AL = ucLowByte;
//Change to OCR3AH and AL

/* Setup clock source and compare match behaviour. */
TCCR1B = ucLowByte;
// Make sure the correct register for TIMER3

/* Enable the interrupt - this is okay as interrupt are currently globally
disabled. */
ucLowByte = TIMSK;
TIMSK = ucLowByte;

too bad no way to mark up my comments


[ Back to the top ]    [ About FreeRTOS ]    [ Privacy ]    [ Sitemap ]    [ ]

Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

NXP tweet showing LPC5500 (ARMv8-M Cortex-M33) running FreeRTOS.

Version 10.1.1 of the FreeRTOS kernel is available for immediate download. MIT licensed.

View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS.


FreeRTOS and other embedded software careers at AWS.

FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers


STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

OpenRTOS and SafeRTOS

Xilinx Microblaze and Zynq partner