FreeRTOS Support Archive
The FreeRTOS support forum is used to obtain active support directly from Real
Time Engineers Ltd. In return for using our top quality software and services for
free, we request you play fair and do your bit to help others too! Sign up
to receive notifications of new support topics then help where you can.
This is a read only archive of threads posted to the FreeRTOS support forum.
The archive is updated every week, so will not always contain the very latest posts.
Use these archive pages to search previous posts. Use the Live FreeRTOS Forum
link to reply to a post, or start a new support thread.
[FreeRTOS Home] [Live FreeRTOS Forum] [FAQ] [Archive Top] [April 2011 Threads]
I have a configuration problem, I'm trying to adapt the atmega323 port -> to Atmega644 but
when I try to run 2 tasks does not work.
My code
#include
#include
#include "FreeRTOS.h"
#include "task.h"
/*-----------------------------------------------------------
* Implementation of functions defined in portable.h for the AVR port.
*----------------------------------------------------------*/
/* Start tasks with interrupts enables. */
#define portFLAGS_INT_ENABLED( ( portSTACK_TYPE ) 0x01 ) /// ....> ????? ist a register?? or interrupt mask register??
/* Hardware constants for timer 1. */
#define portCLEAR_COUNTER_ON_MATCH( ( unsigned char ) 0x08 )
#define portPRESCALE_64( ( unsigned char ) 0x03 )
#define portCLOCK_PRESCALER( ( unsigned long ) 64 )
#define portCOMPARE_MATCH_A_INTERRUPT_ENABLE ( ( unsigned char ) 0x02 ) //ForCOMPARE_MATCH_A_INTERRUPT_ENABLE ATM644
I need your help.
Thanks GuysI used the following code when using a ATmega1284P and a ATmega1281:
/* Start tasks with interrupts enables. */
#define portFLAGS_INT_ENABLED( ( portSTACK_TYPE ) 0x80 )
/* Hardware constants for timer 1. */
#if !(__AVR_ATmega1284P__ || __AVR_ATmega1281__)
#define portCLEAR_COUNTER_ON_MATCH( ( unsigned char ) 0x08 )
#define portPRESCALE_64( ( unsigned char ) 0x03 )
#define portCLOCK_PRESCALER( ( unsigned long ) 64 )
#define portCOMPARE_MATCH_A_INTERRUPT_ENABLE( ( unsigned char ) 0x10 )
#else
#define portCLEAR_COUNTER_ON_MATCH( 1<#define portPRESCALE_1024( (1<#define portPRESCALE_256( 1<#define portPRESCALE_64( (1<#define portCLOCK_PRESCALER( 64 )
#define portCOMPARE_MATCH_A_INTERRUPT_ENABLE( 1<#define TIMSKTIMSK1
#endif
I also change the code for prvSetupTimerInterrupt()
static void prvSetupTimerInterrupt( void )
{
unsigned long ulCompareMatch;
unsigned char 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 long ) 1;
/* Setup compare match value for compare match A. Interrupts are disabled
before this is called so we need not worry here. */
ucLowByte = ( unsigned char ) ( ulCompareMatch & ( unsigned long ) 0xff );
ulCompareMatch >>= 8;
ucHighByte = ( unsigned char ) ( ulCompareMatch & ( unsigned long ) 0xff );
OCR1AH = ucHighByte;
OCR1AL = ucLowByte;
// Generate tick pulses on PD5
//DDRD |= (1< TCCR1A = (0< | (0< | (0< // TOP is OCR1A
/* Setup clock source and compare match behaviour. */
// ucLowByte = portCLEAR_COUNTER_ON_MATCH | portPRESCALE_64;
// TCCR1B = ucLowByte;
TCCR1B = (0< | (0< | (0<
TCCR1C = (0<
/* Enable the interrupt - this is okay as interrupt are currently globally
disabled. */
ucLowByte = TIMSK;
ucLowByte |= portCOMPARE_MATCH_A_INTERRUPT_ENABLE;
TIMSK = ucLowByte;
}
I tested this code with a STK500.
Hope this helps
Bernd
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.