Pumpkin, Inc.

Pumpkin User Forums

Help needed

For issues specific to Atmel's AVR and MegaAVR microcontrollers, including Atmel AVRStudio and ImageCraft's ICCAVR C compiler.

Help needed

Postby KISHOR BANDE » Fri Mar 03, 2006 3:01 am

dear freinds!!
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;
}

KISHOR BANDE
 
Posts: 2
Joined: Wed Mar 01, 2006 12:00 am

Re: Help needed

Postby aek » Fri Mar 03, 2006 8:54 am

See Salvo tutorial tu5 and tu6 -- they use an ISR to call OSTimer(), which then gives you the ability to delay tasks by any number of timer ticks.

The application you posted doesn't use Salvo.

------------------

-------
aek
aek
 
Posts: 1888
Joined: Sat Aug 26, 2000 11:00 pm

Re: Help needed

Postby KISHOR BANDE » Fri Mar 03, 2006 9:09 am

quote:
Originally posted by aek:
See Salvo tutorial tu5 and tu6 -- they use an ISR to call OSTimer(), which then gives you the ability to delay tasks by any number of timer ticks.

The application you posted doesn't use Salvo.


i hav integrated salvo ISR.C ISR.H files with ICCAVR
but i am getting following erros.


): D:prosourcesisr.c(17): Could not find include file "salvocfg.h"
!E C:/salvo/inc/salvo.h(348): C:salvosrcmem.c(30): Could not find include file "salvocfg.h"
C:iccinimakew -f pro.mak
C:iccinimakew.exe: Don't know how to make C:/salvo/inc/salvocfg.h
Done: there are error(s). Exit code: 1

KISHOR BANDE
 
Posts: 2
Joined: Wed Mar 01, 2006 12:00 am

Re: Help needed

Postby aek » Sun Mar 05, 2006 8:06 am

Please see our App Note AN-24 for a step-by-step tutorial on building projects with ICCAVR.
-------
aek
aek
 
Posts: 1888
Joined: Sat Aug 26, 2000 11:00 pm


Return to Atmel AVR and MegaAVR

Who is online

Users browsing this forum: No registered users and 2 guests

cron