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

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