[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[avr-gcc-list] allocation of constant table

From: juan antonio jimenez martinez
Subject: [avr-gcc-list] allocation of constant table
Date: Tue, 30 Aug 2005 18:18:41 +0000

OK, I have my table in the address that I want, but now I have another detail, I have been trying to read back those values to update the OCR2 for the Fast PWM mode of timer2, and I do it in this way:

#include <avr/io.h>
#include <avr/interrupt.h> //para sei(); y cli();
#include <avr/signal.h> // para las rutinas SIGNAL(){};
//#include <avr/pgmspace.h>

#include "./sampler.txt"// my file with 1024 samples of data
//the array is declared as
// __attribute__((section (".flashtable"))) unsigned char tabla[1024]={0x78, ....};
// in the address 0x400 of the program space

volatile unsigned int i=0;

Interrupcion del PWM

        OCR2 = table[i];//actualiza valor de arreglo
        if(i==1023) i=0;

int main(void){

        DDRB = (1<<PB3);
   TCCR2 = (1<<WGM21)|(1<<WGM20)|(1<<COM21)|(1<<CS22)|(1<<CS21);
        //modo FAST PWM, prende OC2 cuando es igual al valor comparado, reloj
        //preescalamiento de 256
        //OCR2 = 51;//para PWM del 80% =204,20%=51
        TIFR = TIFR|(1<<OCIE2);//habilita interrupcion por comparacion en timer2

please can any one give me some clues to read and update the value in the OCR2 register..


reply via email to

[Prev in Thread] Current Thread [Next in Thread]