Pages: [1] 2   Go Down
Author Topic: atmega8 pinout  (Read 2006 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 16
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hey, i was trying to upload my IRremote code (which perfecly works on arduino) to atmega8, to do that i have to generate hex file and with avrdude upload it to atmega8. BUT there is a problem, on atmega8 pins are named like "PB0" and so on. in arduino there are only pins named by numbers and when i am trying to verify IR code on arduino program it says that "PB0" and other atmega8 pins was not declared in the scope. what sould i do?
Logged

SF Bay Area (USA)
Online Online
Tesla Member
***
Karma: 135
Posts: 6787
Strongly opinionated, but not official!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Try PORTB0
Logged

Norfolk UK
Offline Offline
Faraday Member
**
Karma: 70
Posts: 2581
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Pin names are just the same but you may need to change the board type in the IDE to 'Arduino NG or older w/ ATmega8' (assuming the chip has a 16Mhz clock) else you will need a different board.txt definition.
Logged


Offline Offline
Newbie
*
Karma: 0
Posts: 16
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

thanks, but now i'm getting another problem :


C:\Users\PUKIS\Documents\Arduino\libraries\IRremoteeee\IRremote.cpp: In member function 'virtual void IRsend::mark(int)':
C:\Users\PUKIS\Documents\Arduino\libraries\IRremoteeee\IRremote.cpp:172: error: 'TCCR2A' was not declared in this scope
C:\Users\PUKIS\Documents\Arduino\libraries\IRremoteeee\IRremote.cpp:172: error: 'COM2B1' was not declared in this scope
C:\Users\PUKIS\Documents\Arduino\libraries\IRremoteeee\IRremote.cpp: In member function 'virtual void IRsend::space(int)':
C:\Users\PUKIS\Documents\Arduino\libraries\IRremoteeee\IRremote.cpp:180: error: 'TCCR2A' was not declared in this scope
C:\Users\PUKIS\Documents\Arduino\libraries\IRremoteeee\IRremote.cpp:180: error: 'COM2B1' was not declared in this scope
C:\Users\PUKIS\Documents\Arduino\libraries\IRremoteeee\IRremote.cpp: In member function 'void IRsend::enableIROut(int)':
C:\Users\PUKIS\Documents\Arduino\libraries\IRremoteeee\IRremote.cpp:198: error: 'TIMSK2' was not declared in this scope
C:\Users\PUKIS\Documents\Arduino\libraries\IRremoteeee\IRremote.cpp:207: error: 'TCCR2A' was not declared in this scope
C:\Users\PUKIS\Documents\Arduino\libraries\IRremoteeee\IRremote.cpp:208: error: 'TCCR2B' was not declared in this scope
C:\Users\PUKIS\Documents\Arduino\libraries\IRremoteeee\IRremote.cpp:208: error: 'WGM22' was not declared in this scope
C:\Users\PUKIS\Documents\Arduino\libraries\IRremoteeee\IRremote.cpp:211: error: 'OCR2A' was not declared in this scope
C:\Users\PUKIS\Documents\Arduino\libraries\IRremoteeee\IRremote.cpp:212: error: 'OCR2B' was not declared in this scope
C:\Users\PUKIS\Documents\Arduino\libraries\IRremoteeee\IRremote.cpp: In member function 'void IRrecv::enableIRIn()':
C:\Users\PUKIS\Documents\Arduino\libraries\IRremoteeee\IRremote.cpp:224: error: 'TCCR2A' was not declared in this scope
C:\Users\PUKIS\Documents\Arduino\libraries\IRremoteeee\IRremote.cpp:229: error: 'TCCR2B' was not declared in this scope
C:\Users\PUKIS\Documents\Arduino\libraries\IRremoteeee\IRremote.cpp:234: error: 'TIMSK2' was not declared in this scope


but if i choose Arduino NG or older w/atmega168  it doesn't show any problem.
Logged

Norfolk UK
Offline Offline
Faraday Member
**
Karma: 70
Posts: 2581
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I know the mega8 has less PWM's (amongst other things) than the mega328 and it looks like the IRremote library is using some features that don't exist in the mega8. I don't know if it's possible to change/configure the IRlibrary to suit. Might be as well to grab a new 328 as it's pin compatible with the 8 and swap them over.
Logged


London
Offline Offline
Full Member
***
Karma: 0
Posts: 146
Ugi was not declared in this scope
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If you can use D9, D10 and/or D11 for any analogWrite commands that you need then you should be OK on an ATMega8.  These are the only 3 PWM pins on that chip I believe.

It only has one Timer/Counter Control Register, hence no "TCCR2".  The 168 has two, hence it's happy with references to TCCR2.

Edit - re-reading the context, it's probably the IR library that is using TCCR2, which will be harder to change.  However, you may be able to edit the library to use timer 1.  Might be easier to use a '168 or '328 that have a timer 2 available - as Riva suggests.

Ugi
« Last Edit: January 24, 2013, 11:20:21 am by Dr_Ugi » Logged

vermont
Offline Offline
Sr. Member
****
Karma: 8
Posts: 313
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

only has one Timer/Counter Control Register

i think you meant to say "only has Control Registers for two Timer/Counters". 3 pwm are available and this should compile fine for m8 under arduino following rivas advice on ng.
Logged

London
Offline Offline
Full Member
***
Karma: 0
Posts: 146
Ugi was not declared in this scope
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I meant only that TCCR2 exists on the ATMega168 but not on the ATMega8.  TCCR1 exists on both.

It appears that it does not compile on the '8 (following Riva's very appropriate advice) because the compiler is looking for TCCR2 amongst others.  It does compile on the '168 where these exist. 

If the sketch and library refer to PWM pins that are supported on the '8 (D9-11 I believe) then I agree - it should complie fine.  It appears that something does not at the moment and the compiler is looking for registers etc that don't exist on the '8.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 16
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have changed TCCR2 to TCCR0 but still i have these errors:


C:\Users\PUKIS\Documents\Arduino\libraries\IRremoteeee\IRremote.cpp: In member function 'virtual void IRsend::mark(int)':
C:\Users\PUKIS\Documents\Arduino\libraries\IRremoteeee\IRremote.cpp:172: error: 'TCCR2A' was not declared in this scope
C:\Users\PUKIS\Documents\Arduino\libraries\IRremoteeee\IRremote.cpp:172: error: 'COM2B1' was not declared in this scope
C:\Users\PUKIS\Documents\Arduino\libraries\IRremoteeee\IRremote.cpp: In member function 'virtual void IRsend::space(int)':
C:\Users\PUKIS\Documents\Arduino\libraries\IRremoteeee\IRremote.cpp:180: error: 'TCCR2A' was not declared in this scope
C:\Users\PUKIS\Documents\Arduino\libraries\IRremoteeee\IRremote.cpp:180: error: 'COM2B1' was not declared in this scope
C:\Users\PUKIS\Documents\Arduino\libraries\IRremoteeee\IRremote.cpp: In member function 'void IRsend::enableIROut(int)':
C:\Users\PUKIS\Documents\Arduino\libraries\IRremoteeee\IRremote.cpp:198: error: 'TIMSK2' was not declared in this scope
C:\Users\PUKIS\Documents\Arduino\libraries\IRremoteeee\IRremote.cpp:207: error: 'TCCR2A' was not declared in this scope
C:\Users\PUKIS\Documents\Arduino\libraries\IRremoteeee\IRremote.cpp:208: error: 'TCCR2B' was not declared in this scope
C:\Users\PUKIS\Documents\Arduino\libraries\IRremoteeee\IRremote.cpp:208: error: 'WGM22' was not declared in this scope
C:\Users\PUKIS\Documents\Arduino\libraries\IRremoteeee\IRremote.cpp:211: error: 'OCR2A' was not declared in this scope
C:\Users\PUKIS\Documents\Arduino\libraries\IRremoteeee\IRremote.cpp:212: error: 'OCR2B' was not declared in this scope
C:\Users\PUKIS\Documents\Arduino\libraries\IRremoteeee\IRremote.cpp: In member function 'void IRrecv::enableIRIn()':
C:\Users\PUKIS\Documents\Arduino\libraries\IRremoteeee\IRremote.cpp:224: error: 'TCCR2A' was not declared in this scope
C:\Users\PUKIS\Documents\Arduino\libraries\IRremoteeee\IRremote.cpp:229: error: 'TCCR2B' was not declared in this scope
C:\Users\PUKIS\Documents\Arduino\libraries\IRremoteeee\IRremote.cpp:234: error: 'TIMSK2' was not declared in this scope

should i change each of these from 2 to 0?
Logged

SF Bay Area (USA)
Online Online
Tesla Member
***
Karma: 135
Posts: 6787
Strongly opinionated, but not official!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Timer2 is significantly different on an ATmega8 than it is on an ATmega168.  You probably have to move "everything" to a different timer.

Which IRRemote library are you trying to use?  I looked at https://github.com/shirriff/Arduino-IRremote and it already has code to automatically use timer1 on an ATmega8...
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 16
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Timer2 is significantly different on an ATmega8 than it is on an ATmega168.  You probably have to move "everything" to a different timer.

Which IRRemote library are you trying to use?  I looked at https://github.com/shirriff/Arduino-IRremote and it already has code to automatically use timer1 on an ATmega8...


Thank you so so so much!!!!
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 16
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

ok one problem down smiley but now when i am trying to upload program to atmega8 i am getting this error :

avrdude: verification error, first mismatch at byte 0x0000
         0x3f != 0x00
avrdude: verification error; content mismatch
Logged

SF Bay Area (USA)
Online Online
Tesla Member
***
Karma: 135
Posts: 6787
Strongly opinionated, but not official!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Do you have the right bootloader in your mega8?  Or are you using a device programmer?

Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 16
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

i am uploading program with arduino. I don't know if i should burn bootloader into my atmega8, well if i should than i don't really know how :/
Logged

Norfolk UK
Offline Offline
Faraday Member
**
Karma: 70
Posts: 2581
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

i am uploading program with arduino. I don't know if i should burn bootloader into my atmega8, well if i should than i don't really know how :/
You don't need to burn a bootloader as you could always use your UNO (or a device programmer) to program it but it gets tedious using an UNO to keep connecting/disconnecting to program. Look here to see how http://arduino.cc/en/Tutorial/ArduinoISP
I found it easiest to burn a bootloader and then have an FDTI2USB like https://www.sparkfun.com/products/9716? to upload programs and act as a serial monitor.
Logged


Pages: [1] 2   Go Up
Jump to: