Arduino ide and atmega8

atmega 8 using arduino ide

  #include "SoftwareSerial.h"
SoftwareSerial BTserial(2,3);
char c = ' ';
void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  Serial.println("Enter At Commands");
  BTserial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
  BTserial.println("Bluetooth Test");
  Serial.println("Bluetooth Test");
  delay(1000);
}

ERROR:

Arduino: 1.8.2 (Windows 8.1), Board: “ATmega8, 1 MHz (internal), ATmega8”

In file included from D:\softwares\Arduino\arduino-1.8.2\hardware\arduino\avr\cores\arduino/Arduino.h:257:0,

from D:\softwares\Arduino\arduino-1.8.2\hardware\arduino\avr\libraries\SoftwareSerial\src\SoftwareSerial.cpp:43:

D:\softwares\Arduino\arduino-1.8.2\hardware\arduino\avr\libraries\SoftwareSerial\src\SoftwareSerial.cpp: In member function ‘void SoftwareSerial::begin(long int)’:

D:\softwares\Arduino\arduino-1.8.2\hardware\arduino\avr\variants\standard/pins_arduino.h:74:62: error: ‘PCICR’ was not declared in this scope

#define digitalPinToPCICR(p) (((p) >= 0 && (p) <= 21) ? (&PCICR) : ((uint8_t *)0))

^

D:\softwares\Arduino\arduino-1.8.2\hardware\arduino\avr\libraries\SoftwareSerial\src\SoftwareSerial.cpp:319:7: note: in expansion of macro ‘digitalPinToPCICR’

if (digitalPinToPCICR(_receivePin)) {

^

D:\softwares\Arduino\arduino-1.8.2\hardware\arduino\avr\variants\standard/pins_arduino.h:76:49: error: ‘PCMSK2’ was not declared in this scope

#define digitalPinToPCMSK(p) (((p) <= 7) ? (&PCMSK2) : (((p) <= 13) ? (&PCMSK0) : (((p) <= 21) ? (&PCMSK1) : ((uint8_t *)0))))

^

D:\softwares\Arduino\arduino-1.8.2\hardware\arduino\avr\libraries\SoftwareSerial\src\SoftwareSerial.cpp:363:22: note: in expansion of macro ‘digitalPinToPCMSK’

_pcint_maskreg = digitalPinToPCMSK(_receivePin);

^

D:\softwares\Arduino\arduino-1.8.2\hardware\arduino\avr\variants\standard/pins_arduino.h:76:76: error: ‘PCMSK0’ was not declared in this scope

#define digitalPinToPCMSK(p) (((p) <= 7) ? (&PCMSK2) : (((p) <= 13) ? (&PCMSK0) : (((p) <= 21) ? (&PCMSK1) : ((uint8_t *)0))))

^

D:\softwares\Arduino\arduino-1.8.2\hardware\arduino\avr\libraries\SoftwareSerial\src\SoftwareSerial.cpp:363:22: note: in expansion of macro ‘digitalPinToPCMSK’

_pcint_maskreg = digitalPinToPCMSK(_receivePin);

^

D:\softwares\Arduino\arduino-1.8.2\hardware\arduino\avr\variants\standard/pins_arduino.h:76:103: error: ‘PCMSK1’ was not declared in this scope

#define digitalPinToPCMSK(p) (((p) <= 7) ? (&PCMSK2) : (((p) <= 13) ? (&PCMSK0) : (((p) <= 21) ? (&PCMSK1) : ((uint8_t *)0))))

^

D:\softwares\Arduino\arduino-1.8.2\hardware\arduino\avr\libraries\SoftwareSerial\src\SoftwareSerial.cpp:363:22: note: in expansion of macro ‘digitalPinToPCMSK’

_pcint_maskreg = digitalPinToPCMSK(_receivePin);

^

exit status 1
Error compiling for board ATmega8.

no idea what to do. cn any1 help

"Error compiling for board ATmega8."

If you select Uno as board type (328P microcontroller) do you see the same errors?

i didn't get any error while compiling.

but i cant burn the hex.

Arduino: 1.8.2 (Windows 8.1), Board: "ATmega328/328p, 1 MHz (internal), ATmega328p"

Sketch uses 3354 bytes (10%) of program storage space. Maximum is 32768 bytes. Global variables use 333 bytes (16%) of dynamic memory, leaving 1715 bytes for local variables. Maximum is 2048 bytes. avrdude: Expected signature for ATmega328P is 1E 95 0F Double check chip, or use -F to override this check. Wrong microcontroller found. Did you select the right board from the Tools > Board menu?

This report would have more information with "Show verbose output during compilation" option enabled in File -> Preferences.

Ok, if it compiles ok with a 328P board selected, but not with Atmega8 selected, then I would suggest the Atmega8 does hot have the internal hardware resources needed to support the code you are trying.

And then the upload fails as expected with the wrong chip type.

The ATmega8 doesn't have PCINTs which the SoftwareSerial library requires. You'd have to use the hardware UART for this, or replace the chip with an ATmega88 for instance

Any other solution except changing the mcu?

You could dig up the older SoftwareSerial library that didn't use Pin Change interrupts. Or write a new SoftwareSerial library, perhaps using hardware pin interrupts instead of pin change interrupts.

(Are you really running at 1MHz? Why?)

(The SoftwareSerial lib in v0022 does not use Pin Change interrupts.)

i have an external clock of 16Mhz but when m connecting it to atmega i cud not get a perfect 1sec delay. with 1Mhz i cn get 1sec delay perfectly.(cudnt undrstand what to do so 1Mhz).

i tried an older verson of softwareserial but it was giving some diffrent error.(i dnt remember the error now).

westfw: You could dig up the older SoftwareSerial library that didn't use Pin Change interrupts. Or write a new SoftwareSerial library, perhaps using hardware pin interrupts instead of pin change interrupts.

(Are you really running at 1MHz? Why?)

(The SoftwareSerial lib in v0022 does not use Pin Change interrupts.)

could you please send me the link of v0022??

https://www.arduino.cc/en/Main/OldSoftwareReleases#00xx
Note that I’m suggesting you extract the old SoftwareSerial library, not that you use 0022 in its entirety!

I’m interested in this as well, especially adding SoftwareSerial support for the capable ATmega64 and ATmega128, which have eight “real” interrupt pins. After studying the Arduino 0022 copy of the SoftwareSerial library, it seems like it doesn’t use interrupts at all. That’s next to useless :frowning:

I found this blog post about adding support for ATmega8 to the “latest” softwareSerial library. I’ve tried to apply the patch to the library shipped with MegaCore. I’m able to transmit using the ATmega128, but still can’t receive anything. There’s something wrong in the begin() method in the SoftwareSerial.cpp file (line 308++), but I’m not sure how the delay routines should be initialized with because of the different interrupt routines.

EDIT:
A little tweaking and I’m now able to send and receive using “real” interrupts on the ATmega128. Should work perfectly fine on ATmega8 as well (and others such as ATmega16/32)

I’ve attached the library as a ZIP file if anyone wants to help out :slight_smile:

SoftwareSerial.zip (13.1 KB)

it doesn't use interrupts at all. That's next to useless

It worked pretty well for the parallax Basic Stamp, and many other pre-uart microcontrollers. The interrupt-based SoftwareSerial is neat, but it's a pretty uncommon approach, not needed for many applications.