timing registers in atmega128 unreconized in compiler

Go To Last Post
12 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm running into another hurdle google is not fixing..

I am trying to call timing registers. Specifically:

CLKPR=(1<<CLKPS1)|(1<<CLKPS0));
	TIMSK0=(1<<OCIE0A);
	OCR0A= 524;
	TCCR0A=(1<<WGM01)|(0<<WGM00)|(1<<CS01);

and I get a bunch of undeclared identifier stuff back from the compiler

what libraries do they need to call?

I thought
interrupt.h
timer.h
and signal.h would cover it after I got the error and still nothing

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

#include

Make sure that you are using the -mmcu= flag on your compiler command line *and* your linker command line.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks for the reply

yup im using #include
and the device is set to atmega128 in the project options ...dosent that add the proper argurments...it has for me before..

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

err specifically project options of avr studio 4.13 service pack 1

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ok so upon reading the datasheet(yes I do try to read as much as I can before I ask) I figured out they have a slightly diff format from the mega 163 I was porting the code from

slight enough that I breezed by it when trying to use my bank of already working stuff from previous projects

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

well i still have problems...and its going on 9 in the west coast..........

sigh...

looks like im here all night folks...so if anyone has a reccomendation for a bewildered EE with a deliverable due date coming up, holla at me

now for functional stuff

as i change each part I am trying to make it work..right now is the interrupt handleing

Last Edited: Thu. Nov 15, 2007 - 06:42 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Well i got her to compile...for the record if anyone is searching this should make a
internal clock/8 prescale, CTC, overflow on 524 clock...

TIMSK=(1<<OCIE0);
	OCR1B= 524;
	TCCR1B=(1<<WGM01)|(0<<WGM00)|(1<<CS01);

please please correct me if I'm wrong

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
warning: 'TIM0_COMP' appears to be a misspelled signal handler
whats that all about??...its what the data sheet says the register is

First, it is not a register, it is an interrupt vector. Second, the datasheet calls it TIMER0_COMP. Third, the avr-gcc calls it TIMER0_COMP_vect, which is what you should be using.

rubixcubix wrote:
Well i got her to compile...for the record if anyone is searching this should make a
internal clock/8 prescale, CTC, overflow on 524 clock...

TIMSK=(1<<OCIE0);
	OCR1B= 524;
	TCCR1B=(1<<WGM01)|(0<<WGM00)|(1<<CS01);

please please correct me if I'm wrong


Well, OCIE0 and TIMER0_COMP_vect are for timer 0 and TCCR1B and OCR1B are for timer 1, so you will not be getting the results that you want. Also, setting WGM01 sets timer 1 into 9-bit phase correct PWM mode, which is also not what you want (and the highest the timer will count to in that mode is 511, so it will never reach 524). For CTC mode on timer 1 you need to set WGM02, and you would want OCR1A, not OCR1B. And with the pre-scaler set to 8, the timer would overflow in 8 * 524 = 4192 clocks.

Is that enough correction :)

Regards,
Steve A.

The Board helps those that help themselves.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

well it compiled but no go on the actual functionality :( ... it never hits the interrupt call

ISR(TIMER1_COMPB_vect)
{
	recvtimeout++;
	C_SETBIT(testled);
}

thers my interrupt call

	TIMSK=(1<<OCIE0);
	OCR1B= 524;
	TCCR1B=(1<<WGM01)|(0<<WGM00)|(1<<CS01);

I guess im moving in the right direction from my starting point...albeit slowly...
any clue why that code wouldnt make the interrupt trip for me

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

lol you mustaposted right as i did

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

thanks bro

that really helped

scratch my most recent code post as it didnt reflect your changes

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

sei();
recvtimeout=0;
TIMSK=(1<<OCIE1A); //sets up output compare register 1 a
OCR1A= 1000;

TCCR1B=(1<<WGM12)|(1<<CS11);

yup worked