Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT Training




Loading

TIMER0_OVF and TIMER2_OVF

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>

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

/* 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 );

vParTestInitialise();


while(1);

return 0;
}

/*-----------------------------------------------------------*/
ISR(TIMER0_OVF_vect) // INT_0 or INT_1 work out!!!
{
vParTestToggleLED( 1);
vParTestInitialise();
}

void vApplicationIdleHook( void )
{
vCoRoutineSchedule();
}

Thanks, for all!!!!

RE: TIMER0_OVF and TIMER2_OVF

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?

RE: TIMER0_OVF and TIMER2_OVF

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
..\FreeRTOS\Source\portable\GCC\ATMega323

#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. */
ucLowByte = portCLEAR_COUNTER_ON_MATCH | portPRESCALE_64;
TCCR1B = ucLowByte;
// Make sure the correct register for TIMER3

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

too bad no way to mark up my comments

Jay


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




Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.


Free TCP/IP and file system demos for the RTOS


Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

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

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

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

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists