[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
*************************************************************/
SIGNAL(SIG_OUTPUT_COMPARE2) {
OCR2 = table[i];//actualiza valor de arreglo
i++;
if(i==1023) i=0;
}
int main(void){
cli();
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
sei();
//sbi(PORTB,PB3);
for(;;){}
}
please can any one give me some clues to read and update the value in the
OCR2 register..
JAJM
- [avr-gcc-list] allocation of constant table,
juan antonio jimenez martinez <=