Go Down

Topic: Programming Attiny45 with Uno. Problems finding good information. (Read 3330 times) previous topic - next topic

pert

Actually that is caused by a bug in ATTinyCore:
https://github.com/SpenceKonde/ATTinyCore/issues/187
The bug has been fixed but there wasn't a release since that time. yield() is not commonly used so most people are able to use the latest release without any problems but 3Dtj was unlucky to use a library that does use yield(). So the version with the fix is not available for installation via Boards Manager but you can easily do a manual installation of the version of ATTinyCore with the fix like this:
  • Tools > Board > Boards Manager
  • Wait for downloads to finish
  • Scroll down until you see "ATTinyCore by Spence Konde". Click on it.
  • Click the "Remove" button.
  • Wait for the remove process to finish.
  • Download https://github.com/SpenceKonde/ATTinyCore/archive/master.zip
  • Copy the folder ATTinyCore-master from the downloaded file to {sketchbook folder}/hardware. If you don't know the location of your sketchbook folder you can find/set it at File > Preferences > Sketchbook location. If the hardware subfolder of your sketchbook folder doesn't already exist then you need to create it.
  • In the Arduino IDE's Boards Manager, click the "Close" button. If you did the manual installation of ATTinycore while Boards Manager was open then the newly installed ATTinyCore will have been automatically detected by the IDE. If you exited Boards Manager before completing the installation then you only need to close all Arduino IDE windows and then start the IDE again for the installation to be recognized.

DrAzzy

Thanks for doing my tech support for me, Pert!

My hope is that I'll be able to do a release this weekend - it's been a while.
ATTinyCore for x4/x5/x61/x7/x8/x41/1634/828/x313 megaTinyCore for the megaavr ATtinies - Board Manager:
http://drazzy.com/package_drazzy.com_index.json
ATtiny breakouts, mosfets, awesome prototyping board in my store http://tindie.com/stores/DrAzzy

3Dtj

I'll check the code again.   Based upon the sketch, would you agree the ATtiny45 should be able to handle it?  Is it possible that I'm declaring a pin on the ATtiny45 that is unable to support a LoRa function?

3Dtj

Code: [Select]

/*
  LoRa Duplex communication

  Sends a message every half second, and polls continually
  for new incoming messages. Implements a one-byte addressing scheme,
  with 0xFF as the broadcast address.

  Uses readString() from Stream class to read payload. The Stream class'
  timeout may affect other functuons, like the radio's callback.

  created 28 April 2017
  by Tom Igoe
*/
#include <SPI.h>              // include libraries
#include <LoRa.h>


const int receiveLED = 3;
const int csPin = 0;          // LoRa radio chip select
const int resetPin = 5;       // LoRa radio reset
const int irqPin = 4;         // change for your board; must be a hardware interrupt pin

byte localAddress = 0xFF;     // address of this device
byte destination = 0xBB;      // destination to send to
byte syncWord = 0xB4;        // sync word (network ID)
byte spreadingFactor = 8;    // spreading factor (6-12)


void setup() {
  LoRa.setPins(csPin, resetPin, irqPin);  //set CS, reset, IRQ pin
  LoRa.begin(900E6);              // initialize ratio at 900 MHz

  LoRa.setSyncWord(syncWord);
  LoRa.setSpreadingFactor(spreadingFactor);
  LoRa.setTimeout(10);
  pinMode(receiveLED, OUTPUT); // set the I/O pin modes
}

void onReceive(int packetSize) {
  if (packetSize == 0) return;          // if there's no packet, return
  digitalWrite(receiveLED, HIGH);       // turn on the receive LED

  // read packet header bytes
  int recipient = LoRa.read();          // recipient address
  byte msgLength = LoRa.read();    // incoming msg length
  String incoming = LoRa.readString();  //payload of packet


  // if the recipient isn't this device or broadcast,
  if (recipient != localAddress && recipient != 0xFF) {
    return;                             // skip rest of function
    digitalWrite(receiveLED, LOW);      // turn off receive LED
  }
}


3Dtj

Sorry.  Didn't see pert's response after posting the above.  I will try the updated library tonight.

3Dtj

3Dtj

Hmm.   I removed the Spence core and downloaded the AATinyCore-master.zip using the above link.  Do I need to install the Spence file from the board manger again?  I don't see options to select the ATTiny boards when I go into the board menu of the IDE and I'm not able to open the avrdude.conf file from the master.zip

pert

Do I need to install the Spence file from the board manger again?
No, don't do that. The .zip file contains the same core but with all the latest development work in it, rather than the release version you get from Boards Manager, which is missing those changes.

I don't see options to select the ATTiny boards when I go into the board menu of the IDE and I'm not able to open the avrdude.conf file from the master.zip
That means you didn't do the installation correctly.

I'm not able to open the avrdude.conf file from the master.zip
You weren't supposed to leave the folder in the .zip file. I said "Copy the folder ATTinyCore-master from the downloaded file" because, at least on Windows, you can treat .zip files as folders and copy their contents out of them without actually going through an unzip stage. If you put the .zip file in the hardware folder then you need to unzip it. The folder structure should look like this:

{sketchbook folder}
|_hardware
   |_ATTinyCore-master
      |_avr

Make sure to not create an extra folder level between the hardware folder and the avr folder.

3Dtj

We are making progress.   I did have an extra subfolder inserted thus removed that and was able to see ATTiny45 as a board selection.  Upon compiling, I received a new error message:

Code: [Select]

Archiving built core (caching) in: C:\Users\TBK\AppData\Local\Temp\arduino_cache_732459\core\core_ATTinyCore-master_avr_attinyx5_LTO_disable,TimerClockSource_default,chip_45,clock_8internal,bod_disable_3652342df78470b424b7590a57f0d9c7.a
C:\Users\TBK\AppData\Local\Temp\arduino_build_648684/core\core.a(main.cpp.o): In function `main':

C:\Users\TBK\Documents\Arduino\hardware\ATTinyCore-master\avr\cores\tiny/main.cpp:13: undefined reference to `loop'

collect2.exe: error: ld returned 1 exit status

exit status 1
Error compiling for board ATtiny25/45/85.



So close to getting this to work.  What recommendation do you have?   Really appreciate the help pert.

pert

Typically this error means that the sketch you're compiling doesn't contain a loop function. Every sketch must have a setup and a loop function, even if they are left empty.

Try this:
  • File > New
  • Sketch > Verify/compile

Does the error still occur?

3Dtj

No error occurred when I created a new sketch and compiled as you recommended.   I did find where I had removed the previous void loop (because there was no code).  I re-entered the void loop command to address that issue.  I attempted to compile the updated code an received the following error:


Code: [Select]

Build options changed, rebuilding all
Archiving built core (caching) in: C:\Users\TBK\AppData\Local\Temp\arduino_cache_458644\core\core_ATTinyCore-master_avr_attinyx5_LTO_disable,TimerClockSource_default,chip_45,clock_8internal,bod_disable_3652342df78470b424b7590a57f0d9c7.a
Sketch uses 2790 bytes (68%) of program storage space. Maximum is 4096 bytes.
Global variables use 70 bytes (27%) of dynamic memory, leaving 186 bytes for local variables. Maximum is 256 bytes.
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0xae
avrdude: stk500_recv(): programmer is not responding
Problem uploading to board.  See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0xae
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0xae
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0xae
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0xae
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0xae
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0xae
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0xae
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0xae
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0xae



Is 0xae referring to the local or destination that I used for the LoRa addresses in my sketch?

wilykat

Not responding usually indicates something's not getting through. Are the wiring correct? If you used Arduino as ISP, did you upload ArduinoISP sketch first? Set the programmer correctly in the menu? (ArduinoISP and Arduino as ISP aren't the same!)  Maybe a pullup resistor from ATTiny's reset pin to 5v?

3Dtj

I made a slight change to the code and seems to be compiling but now it says sketch is too big (exceeds by 122%) but I only added a few lines of code.  Should just a few lines of code really exceed the storage of the ATtiny45??  Would an ATTiny85 solve the issue if it really is a matter or storage?

 

CrossRoads

Compare the #s.
Attiny 25/45/85:
2/4/8K Bytes of In-System Programmable Program Memory Flash
128/256/512 Bytes Internal SRAM
128/256/512 Bytes In-System Programmable EEPROM


Double the memory from 45 to 85.

Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

pert

Should just a few lines of code really exceed the storage of the ATtiny45?
That absolutely depends on the lines of code. A single line could do that or not increase the program size at all.

Would an ATTiny85 solve the issue if it really is a matter or storage?
Yes. If you're currently at 5 kB and an ATTiny85 is 8 kB then it gives you some breathing room but you can fill up an ATtiny85 pretty fast also. It's fun to see how much you can do with very limited resources but you can't just expect to be able to keep adding features to your program indefinitely, especially if you're not willing to do a lot of work to optimize your code down as small as possible.

3Dtj

Fascinating that what in my mind is hardly any code at all is causing the limitation issue.

Code: [Select]


Sketch uses 5006 bytes (122%) of program storage space. Maximum is 4096 bytes.

Global variables use 84 bytes (32%) of dynamic memory, leaving 172 bytes for local variables. Maximum is 256 bytes.
Sketch too big; see http://www.arduino.cc/en/Guide/Troubleshooting#size for tips on reducing it.
Error compiling for board ATtiny25/45/85.


Guess I'm express ordering from Adafruit for ATtiny85 chips.  Will get the chips this weekend and give you an update.  Again I appreciate your assistance in this effort.

3Dtj

Go Up