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 <stdlib.h>
#include <avr/interrupt.h>
#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 Guys
Help Porting Atmega644->FreeRtos
Help Porting Atmega644->FreeRtos
I 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<<COM1A1 )
#define portPRESCALE_1024 ( (1<<CS12) | (1<<CS10) )
#define portPRESCALE_256 ( 1<<CS12 )
#define portPRESCALE_64 ( (1<<CS11) | (1<<CS10) )
#define portCLOCK_PRESCALER ( 64 )
#define portCOMPARE_MATCH_A_INTERRUPT_ENABLE ( 1<<OCIE1A )
#define TIMSK TIMSK1
#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<<PD5);
TCCR1A = (0<<COM1A1) | (0<<COM1A0) // normal operation (or toggle OC1A = PD5 on compare match)
| (0<<COM1B1) | (0<<COM1B0) // normal operation
| (0<<WGM11) | (0<<WGM10); // CTC (together with WGM12 and WGM13)
// TOP is OCR1A
/* Setup clock source and compare match behaviour. */
// ucLowByte = portCLEAR_COUNTER_ON_MATCH | portPRESCALE_64;
// TCCR1B = ucLowByte;
TCCR1B = (0<<ICNC1) | (0<<ICES1) // Noise Canceler: Off
| (0<<WGM13) | (1<<WGM12)
| (0<<CS12) | (1<<CS11) | (1<<CS10); // no prescaler, source = sys_clk
TCCR1C = (0<<FOC1A) | (0<<FOC1B); // reserved in PWM, set to zero
/* 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