Go Down

Topic: New megaTinyCore for 1-series and 0-series ATtiny (like 1616, 3217, etc) (Read 21124 times) previous topic - next topic

terje1055

I am trying to compile this example code for SD card datalogger, but get the error message below when I choose ATTiny3217. It works if I choose, for example, Arduino Uno...

Any help appreciated. Thanks.

Arduino 1.8.13
MegaTinyCore 2.0.5


Code: [Select]
/*
  SD card datalogger

  This example shows how to log data from three analog sensors
  to an SD card using the SD library.

  The circuit:
   analog sensors on analog ins 0, 1, and 2
   SD card attached to SPI bus as follows:
 ** MOSI - pin 11
 ** MISO - pin 12
 ** CLK - pin 13
 ** CS - pin 4 (for MKRZero SD: SDCARD_SS_PIN)

  created  24 Nov 2010
  modified 9 Apr 2012
  by Tom Igoe

  This example code is in the public domain.

*/

#include <SPI.h>
#include <SD.h>

const int chipSelect = 4;

void setup() {
  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }


  Serial.print("Initializing SD card...");

  // see if the card is present and can be initialized:
  if (!SD.begin(chipSelect)) {
    Serial.println("Card failed, or not present");
    // don't do anything more:
    while (1);
  }
  Serial.println("card initialized.");
}

void loop() {
  // make a string for assembling the data to log:
  String dataString = "";

  // read three sensors and append to the string:
  for (int analogPin = 0; analogPin < 3; analogPin++) {
    int sensor = analogRead(analogPin);
    dataString += String(sensor);
    if (analogPin < 2) {
      dataString += ",";
    }
  }

  // open the file. note that only one file can be open at a time,
  // so you have to close this one before opening another.
  File dataFile = SD.open("datalog.txt", FILE_WRITE);

  // if the file is available, write to it:
  if (dataFile) {
    dataFile.println(dataString);
    dataFile.close();
    // print to the serial port too:
    Serial.println(dataString);
  }
  // if the file isn't open, pop up an error:
  else {
    Serial.println("error opening datalog.txt");
  }
}



Error compiling for board ATtiny3217/1617/1607/817/807/417:


Code: [Select]
Arduino: 1.8.13 (Windows 10), Board: "ATtiny3217/1617/1607/817/807/417, ATtiny3217, 20 MHz, 4.2V (20 MHZ or less), Disabled, Disabled, EEPROM retained, Enabled (default timer), Closer to 5v"


In file included from C:\Program Files (x86)\Arduino\libraries\SD\src/utility/Sd2Card.h:26:0,

                 from C:\Program Files (x86)\Arduino\libraries\SD\src/utility/SdFat.h:29,

                 from C:\Program Files (x86)\Arduino\libraries\SD\src/SD.h:20,

                 from C:\Program Files (x86)\Arduino\libraries\SD\examples\Datalogger\Datalogger.ino:24:

C:\Program Files (x86)\Arduino\libraries\SD\src/utility/Sd2PinMap.h:438:5: error: 'DDRD' was not declared in this scope

   {&DDRD, &PIND, &PORTD, 0},  // D0  0

     ^~~~

C:\Program Files (x86)\Arduino\libraries\SD\src/utility/Sd2PinMap.h:438:5: note: suggested alternative: 'VDD'

   {&DDRD, &PIND, &PORTD, 0},  // D0  0

     ^~~~

     VDD

C:\Program Files (x86)\Arduino\libraries\SD\src/utility/Sd2PinMap.h:438:12: error: 'PIND' was not declared in this scope

   {&DDRD, &PIND, &PORTD, 0},  // D0  0

            ^~~~





.
.
.
.








In file included from C:\Users\tea\AppData\Local\Arduino15\packages\megaTinyCore\hardware\megaavr\2.0.5\cores\arduino/UART.h:28:0,

                 from C:\Users\tea\AppData\Local\Arduino15\packages\megaTinyCore\hardware\megaavr\2.0.5\cores\arduino/Arduino.h:314,

                 from sketch\Datalogger.ino.cpp:1:

C:\Users\tea\AppData\Local\Arduino15\packages\megaTinyCore\hardware\megaavr\2.0.5\variants\txy7/pins_arduino.h:77:79: error: 'PIN_MOSI_SCK' was not declared in this scope

 #define MOSI ((uint8_t) (PORTMUX.CTRLB&PORTMUX_SPI0_bm?PIN_SPI_MOSI_PINSWAP_1:PIN_MOSI_SCK))

                                                                               ^

C:\Program Files (x86)\Arduino\libraries\SD\src/utility/Sd2Card.h:79:35: note: in expansion of macro 'MOSI'

     uint8_t const  SPI_MOSI_PIN = MOSI;

                                   ^~~~

C:\Users\tea\AppData\Local\Arduino15\packages\megaTinyCore\hardware\megaavr\2.0.5\variants\txy7/pins_arduino.h:77:79: note: suggested alternative: 'PIN_SPI_SCK'

 #define MOSI ((uint8_t) (PORTMUX.CTRLB&PORTMUX_SPI0_bm?PIN_SPI_MOSI_PINSWAP_1:PIN_MOSI_SCK))

                                                                               ^

C:\Program Files (x86)\Arduino\libraries\SD\src/utility/Sd2Card.h:79:35: note: in expansion of macro 'MOSI'

     uint8_t const  SPI_MOSI_PIN = MOSI;

                                   ^~~~

C:\Users\tea\AppData\Local\Arduino15\packages\megaTinyCore\hardware\megaavr\2.0.5\variants\txy7/pins_arduino.h:78:79: error: 'PIN_MISO_SCK' was not declared in this scope

 #define MISO ((uint8_t) (PORTMUX.CTRLB&PORTMUX_SPI0_bm?PIN_SPI_MISO_PINSWAP_1:PIN_MISO_SCK))

                                                                               ^

C:\Program Files (x86)\Arduino\libraries\SD\src/utility/Sd2Card.h:81:35: note: in expansion of macro 'MISO'

     uint8_t const  SPI_MISO_PIN = MISO;

                                   ^~~~

C:\Users\tea\AppData\Local\Arduino15\packages\megaTinyCore\hardware\megaavr\2.0.5\variants\txy7/pins_arduino.h:78:79: note: suggested alternative: 'PIN_SPI_SCK'

 #define MISO ((uint8_t) (PORTMUX.CTRLB&PORTMUX_SPI0_bm?PIN_SPI_MISO_PINSWAP_1:PIN_MISO_SCK))

                                                                               ^

C:\Program Files (x86)\Arduino\libraries\SD\src/utility/Sd2Card.h:81:35: note: in expansion of macro 'MISO'

     uint8_t const  SPI_MISO_PIN = MISO;

                                   ^~~~

exit status 1

Error compiling for board ATtiny3217/1617/1607/817/807/417.












CrossRoads

Code: [Select]
C:\Program Files (x86)\Arduino\libraries\SD\src/utility/Sd2PinMap.h:438:5: error: 'DDRD' was not declared in this scope
   {&DDRD, &PIND, &PORTD, 0},  // D0  0
     ^~~~


That indicates the code is trying to access Port D.
The 3217 only has Port A, with bits 0 to 7,
Port B with bits, with bits 0 to 7, and
Port C with bits 0 to 5.

The 20 pin SOIC has a few less bits:
Port A, with bits 0 to 7,
Port B with bits, with bits 0 to 5, and
Port C with bits 0 to 3.


Code: [Select]

C:\Users\tea\AppData\Local\Arduino15\packages\megaTinyCore\hardware\megaavr\2.0.5\variants\txy7/pins_arduino.h:77:79: error: 'PIN_MOSI_SCK' was not declared in this scope

 #define MOSI ((uint8_t) (PORTMUX.CTRLB&PORTMUX_SPI0_bm?PIN_SPI_MOSI_PINSWAP_1:PIN_MOSI_SCK))

                                                                              ^


MOSI can be on PA1 or PC2. Maybe this is setting it to be on a different pin?
I am not sure if PORTMUX.CTRLB means it is trying to use a PORTB pin.
Same with the SCK and MISO errors.



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.

dlloyd

Looks like your SD card datalogger library was written for the ATmega328P ... the ATiny3217 has different registers.

windoze_killa

Hi All,

Not sure what I have done wrong but I am getting the following error.

avrdude: jtagmkII_getsync(): sign-on command: status -1

It keeps repeating itself trying to upload my sketch. It compiles ok.

I have installed jtag2updi on a nano and set the tinycore to a 3217. AmI missing something else?
Engineers design things.....technicians make them work.

I don't need anti-static wrist straps.....an instructor years ago told me I had no potential.

windoze_killa

Update. Seems to be working sort of.

Now I have this error message.




Arduino: 1.8.13 (Linux), Board: "ATtiny3217/1617/1607/817/807/417, ATtiny3217, 20 MHz, 1.8V (5 MHz or less), Disabled, Disabled, EEPROM retained, RTC w/w32khz xtal (no micros), Closer to 5v"

Sketch uses 21382 bytes (65%) of program storage space. Maximum is 32768 bytes.
Global variables use 150 bytes (7%) of dynamic memory, leaving 1898 bytes for local variables. Maximum is 2048 bytes.
/home/jason/snap/arduino/41/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino17/bin/avrdude -C/home/jason/snap/arduino/41/.arduino15/packages/megaTinyCore/hardware/megaavr/2.0.5/avrdude.conf -v -pattiny3217 -cjtag2updi -P/dev/ttyUSB1 -Uflash:w:/tmp/arduino_build_356461/PI_GPI_ATRE_OLED_TNR_NANO.ino.hex:i

avrdude: Version 6.3-20190619
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "/home/jason/snap/arduino/41/.arduino15/packages/megaTinyCore/hardware/megaavr/2.0.5/avrdude.conf"
         User configuration file is "/home/jason/snap/arduino/41/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping

         Using Port                    : /dev/ttyUSB1
         Using Programmer              : jtag2updi
avrdude: jtagmkII_getsync(): sign-on command: status -1
JTAG ICE mkII sign-on message:
Communications protocol version: 1
M_MCU:
  boot-loader FW version:        1
  firmware version:              6.00
  hardware version:              1
S_MCU:
  boot-loader FW version:        1
  firmware version:              6.00
  hardware version:              1
Serial number:                   00:00:00:00:00:00
Device ID:                       JTAGICE mkII
         AVR Part                      : ATtiny3217
         Chip Erase delay              : 0 us
         PAGEL                         : P00
         BS2                           : P00
         RESET disposition             : dedicated
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 0
         StabDelay                     : 0
         CmdexeDelay                   : 0
         SyncLoops                     : 0
         ByteDelay                     : 0
         PollIndex                     : 0
         PollValue                     : 0x00
         Memory Detail                 :

                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00
           prodsig        0     0     0    0 no         61   61      0     0     0 0x00 0x00
           fuses          0     0     0    0 no          9    0      0     0     0 0x00 0x00
           fuse0          0     0     0    0 no          1    0      0     0     0 0x00 0x00
           fuse1          0     0     0    0 no          1    0      0     0     0 0x00 0x00
           fuse2          0     0     0    0 no          1    0      0     0     0 0x00 0x00
           fuse4          0     0     0    0 no          1    0      0     0     0 0x00 0x00
           fuse5          0     0     0    0 no          1    0      0     0     0 0x00 0x00
           fuse6          0     0     0    0 no          1    0      0     0     0 0x00 0x00
           fuse7          0     0     0    0 no          1    0      0     0     0 0x00 0x00
           fuse8          0     0     0    0 no          1    0      0     0     0 0x00 0x00
           lock           0     0     0    0 no          1    0      0     0     0 0x00 0x00
           data           0     0     0    0 no          0    0      0     0     0 0x00 0x00
           usersig        0     0     0    0 no         32   32      0     0     0 0x00 0x00
           flash          0     0     0    0 no      32768  128      0     0     0 0x00 0x00
           eeprom         0     0     0    0 no        256   64      0     0     0 0x00 0x00

         Programmer Type : JTAGMKII_PDI
         Description     : JTAGv2 to UPDI bridge
         M_MCU hardware version: 1
         M_MCU firmware version: 6.00
         S_MCU hardware version: 1
         S_MCU firmware version: 6.00
         Serial number:          00:00:00:00:00:00
         Vtarget         : 5.0 V

avrdude: jtagmkII_initialize(): Cannot locate "flash" and "boot" memories in description
avrdude: AVR device initialized and ready to accept instructions

Reading | avrdude: jtagmkII_program_enable(): timeout/error communicating with programmer (status -1)
avr_read(): error reading address 0x0000
    read operation not supported for memory "signature"
avrdude: error reading signature data for part "ATtiny3217", rc=-2
avrdude: error reading signature data, rc=-2
avrdude: jtagmkII_close(): timeout/error communicating with programmer (status -1)
avrdude: jtagmkII_close(): timeout/error communicating with programmer (status -1)

avrdude done.  Thank you.

the selected serial port
 does not exist or your board is not connected


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




Any Ideas?
Engineers design things.....technicians make them work.

I don't need anti-static wrist straps.....an instructor years ago told me I had no potential.

windoze_killa

Yet  another update.

Brain failure.

copper to air ratio problem.

Forgot to install a vital 0 ohm resistor of the board. Uploads fine.
Engineers design things.....technicians make them work.

I don't need anti-static wrist straps.....an instructor years ago told me I had no potential.

pert

Well, if you're going to suffer from a bad copper:air, too low is always better than too high!

windoze_killa

Ok. New problem.

As some may be aware I have been trying to make a gear indicator for my motorbike.

Obviously because I am using a tiny3217 I have to program it using UPDI and it is now working.

The problem is the display does start working until I have reached 3V on the UPDI pin (also A0) and yes I need to use this pin. Is there something I should be doing to enable this pin as an analog in pin after programming?
Engineers design things.....technicians make them work.

I don't need anti-static wrist straps.....an instructor years ago told me I had no potential.

windoze_killa

Well, if you're going to suffer from a bad copper:air, too low is always better than too high!
Also know as a carbon based failure somewhere between the chair and the workbench.
Engineers design things.....technicians make them work.

I don't need anti-static wrist straps.....an instructor years ago told me I had no potential.

windoze_killa

Another post for Drazzy.

I know you probably had a very good reason for doing it but not paying attention caused me some dramas using on of your break out boards.

The numbering along the sides of the board don't correlate to the pins on the chip. Would have saved some trouble if they did.
Engineers design things.....technicians make them work.

I don't need anti-static wrist straps.....an instructor years ago told me I had no potential.

grandaspanna

Has anyone found an OLED library that works with the attiny412? At a minimum, I'd like to display text (numbers only will do). Most recently I've tried SH1106lib, but getting errors. The first is if I enabled HW i2c, it says the 412 doesn't have it. If I disabled HW i2c, I'm getting "impossible constraint in i2c_read" which is part of the SoftwareI2C library.

I have a plan B to switch to a larger package, but would be nice to know :-)

windoze_killa

What display are you using? I am using an SSD1306 with a tiny3217 and it works fine.
Engineers design things.....technicians make them work.

I don't need anti-static wrist straps.....an instructor years ago told me I had no potential.

grandaspanna

It's a generic 128x32 i2c module. I've had it happily working with u8x8 and u8g2 with an attiny1614, but the code/memory footprint is too big for the 4k of the 412.

windoze_killa

What about modifying the library and remove any characters you don't need.
Engineers design things.....technicians make them work.

I don't need anti-static wrist straps.....an instructor years ago told me I had no potential.

grandaspanna

With the u8x8 library and no fonts at all, the code is still too big at close to 5k.

I'd rather switch to a part with a bit more code space than hack standard libraries too much. The difference in cost is small for my volumes.

Go Up