Quality RTOS & Embedded Software

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


Loading

Help Porting Atmega644->FreeRtos

Posted by Slaxtrack on April 27, 2011
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 Guys

RE: Help Porting Atmega644->FreeRtos

Posted by Bernd Fink on April 27, 2011
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<#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


[ 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.

Meet Richard Barry and learn about running FreeRTOS on RISC-V at FOSDEM 2019

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.


Careers

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

Renesas

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