i am new to atmel ics
i am using immagecraft compiler can any baody tell me why my programm is not working. i have down-loaded Salvo demo, but how to integrate it to get 1 sec accurate delay
#include <iom128v.h>
#include <macros.h>
#define posel PORTD
#define rdsel1 0x00
#define rdsel2 0x20
#define rdsel3 0x40
#define rdsel4 0x60
#define rdsel5 0x80
#define rdsel6 0xa0
#define rdsel7 0xc0
#define rdsel8 0xe0
unsigned long ulTick;
void port_init(void)
{
DDRA=0xFF;
PORTA=0x00;
//DDRB=0xf7;
//PORTB=0x08;
//DDRC=0xff;
//PORTC=0x00;
DDRD=0xe0;
PORTD=0x1f;
DDRE=0xee;
PORTE=0x11;
}
//TIMER1 initialize - prescale:1 desired value: 1mSec actual value:
//1.000mSec (0.0%)
void timer1_init(void)
{
TCCR1B = 0x00; //stop
TCNT1H = 0xF0; //setup
TCNT1L = 0x60;
OCR1AH = 0x0F;
OCR1AL = 0xA0;
OCR1BH = 0x0F;
OCR1BL = 0xA0;
TCCR1A = 0x00;
TCCR1B = 0x01; //start Timer
}
#pragma interrupt_handler timer1_ovf_isr:9
void timer1_ovf_isr(void)
{
TCNT1H = 0xF0; //reload counter high value
TCNT1L = 0x60; //reload counter low value
if (ulTick > 0)
ulTick--;
}
void delayMs(unsigned long mSec)
{
CLI(); // disable all interrupts
ulTick = mSec;
SEI(); // re-enable interrupts
while (ulTick>0);
}
//call this routine to initialize all peripherals
void init_devices(void)
{
//stop errant interrupts until set up
CLI(); //disable all interrupts
XDIV = 0x00; //xtal divider
XMCRA = 0x00; //external memory
port_init();
timer1_init();
MCUCR = 0x00;
//EICRA = 0x00; //extended ext ints
//EICRB = 0x00; //extended ext ints
EIMSK = 0x00;
TIMSK = 0x04;
TIFR = 0x04 //timer interrupt sources
//ETIMSK = 0x00; //extended timer interrupt sources
SEI(); //re-enable interrupts
//all peripherals are now initialized
}
void main(void){
int i,j;
ulTick = 0;
init_devices();
while(1){
PORTA=0b00000000;
posel=0x00;
LOW_HIGH();
delayMs(10);
PORTA=0b11111111;
posel=0x00;
LOW_HIGH();
delayMs(10);
}
}
void LOW_HIGH(void)
{ PORTE=0b01000000;
PORTE=0b00000000;
}