0

I am writing a program in Atmel Studio 7 that I just installed and started using. I have set up the studio for Arduino and added the Atmega128 to the library of supported chips. All is good there. When I try to use the SoftwareSerial library and compile, I get an error that Atmega128 and Atmega64 do not support SoftwareSerial. Why is this? What is so different about this AVR over the atmega328, etc that it will not support the library. Is there a better approach to use SoftwareSerial or SoftUart on the atmega128? Thanks

Eddie
  • 39
  • 10

2 Answers2

0

Did you run into this compile error: This version of NewSoftSerial supports only 20, 16 and 8MHz processors?

This comes from these defines in the cpp file. It might work if you define F_CPU to be 8000000, and make sure that you actually set the register to make that the clock speed. Some processors use a slower clock speed by default. Consult the hardware manual.

Note that F_CPU needs to be defined before the NewSoftwareSerial.cpp file is processed. You can create defines right in the command line with a D switch.

#if F_CPU == 16000000

[snip]

#elif F_CPU == 8000000

[snip]

#elif F_CPU == 20000000

[snip]

#else

#error This version of NewSoftSerial supports only 20, 16 and 8MHz processors

#endif
UncleO
  • 8,299
  • 21
  • 29
  • Hi, thanks for the reply. I did not get F_CPU error on compiling. And yes, I have set the F_CPU to 16MHz. The only error is that one specifically stating "ATmega64 and ATmega128 doesn't support SoftSerial!". When I look in the SoftwareSerial.h file, its actually coded that way on line 44. – Eddie Dec 03 '16 at 01:59
0

Through my research, while using the Arduino libraries and set up, their included SoftwareSerial library does not support the atMega64 and atMega128 because of the differences in the PIN and interrupt on these chips. I have successfully set up softserial on other GPIO pins on the atMega128 by modifying this example. This example is only for transmitting. I am still working on the receive portion because it involves setting up interrupts and clocking. A key note to remember is to make sure your clock settings match throughout your project and the serial bauds are set properly. I tested my code using several different baud rates.

As a side note for beginners, I have found that testing with an Arduino is great. However, when trying to move to a custom built C project, it is extremely difficult to migrate from the Arduino project to a clean C project. In my opinion, its almost easier to just learn C and start testing within the Atmel Studio environment and stay away from Arduino. I sope this helps someone starting out with programming.

Eddie
  • 39
  • 10