IDE to develop ATTiny404

I use a Nano to build the UDPI interface and try to blink a LED on a bare metal ATTiny404 chip. It is successful.
However, I choose one pin ( pin 11 of the IC package (SOP14) or from the data sheet , it is PA1 / AIN 1 ) as the analog pin.
I can make it blink a LED using the following command.
pinMode(8,OUTPUT);
digitalWrite(8,HIGH);
digitalWrite(8,LOW);
I have no idea why it is 8 by the way.

When I try to change the pin as analog input
pinMode(A8,INPUT); // which I suppose if digitalmode is 8, then analog is A8
however the program fails to compile.

Also, do the IDE have a ATTiny404 library to access the ATTiny404 manufacturer ID.
I wish to have it so each MCU can communicate a different key

Thanks for looking and have a nice day.

There is (in simple terms) a "translation" from the number 8 to PA1. There will be a similar "translation" for analogue inputs. I'm not familiar with the ATTiny404, if it has one analogue input, it should be A0, else it's trial an error to find the mapping for the analog input.

Which core do you use? You can start digging through there.

Your topic is not really related to Interfacing w/ Software on the computer and hence has been moved to a more suitable location on the forum.

You can't make assumptions about a pin's number when you change it's function. The core I use for my Attiny85 has this diagram https://github.com/SpenceKonde/ATTinyCore/blob/master/avr/extras/ATtiny_x5.md showing that for my chip. It doesn't look like there is one for the 404 there though, but there may be info with whatever core you used, like sterretje mentioned.

This? https://github.com/SpenceKonde/megaTinyCore/blob/master/megaavr/extras/ATtiny_x04.md

1 Like

pinMode(x, INPUT) does NOT usually change the pin to an analog input (but rather, to a digital input.) I'm not sure if there's a specific command for switching to analog mode, or whether just using analogRead() should do it. (assuming that the pin number is correct. Tiny404 doesn't HAVE an "A8." PA1 looks to be "A1")

(Arduino "pin numbers" are normally completely arbitrary, and based on some particular board. If you're not using a particular board, you should be able to use symbols like "PIN_PA1" to select pins based on the chip port/pin numbers. See ...variants/txy4/variant.h)

Not sure if you want the device ID or the device serial number, but (assuming you are using MegaTinyCore) this prints both.

void setup() {
  Serial.begin(115200);
}

void loop() {
  Serial.print("the (3 byte long) device ID is: ");
  Serial.print(SIGROW_DEVICEID2, HEX);
  Serial.print(SIGROW_DEVICEID1, HEX);
  Serial.println(SIGROW_DEVICEID0, HEX);
  Serial.print("the (10 byte long) device serial number is: ");
  Serial.print(SIGROW_SERNUM9, HEX);
  Serial.print(SIGROW_SERNUM8, HEX);
  Serial.print(SIGROW_SERNUM7, HEX);
  Serial.print(SIGROW_SERNUM6, HEX);
  Serial.print(SIGROW_SERNUM5, HEX);
  Serial.print(SIGROW_SERNUM4, HEX);
  Serial.print(SIGROW_SERNUM3, HEX);
  Serial.print(SIGROW_SERNUM2, HEX);
  Serial.print(SIGROW_SERNUM1, HEX);
  Serial.println(SIGROW_SERNUM0, HEX);
  delay(5000);
}

Thank you very much for all your help. I now uses something like
PORTA.DIRCLR = 0b11110100;
PORTA.OUT = PORTA.IN | 0b00001000; // toggle high the pin
ADC0.MUXPOS = ADC_MUXPOS_AIN1_gc;
to directly address the registers and keep on debugging

and these links provides information that I cannot replicate

https://microchipsupport.force.com/s/article/Serial-number-in-AVR---Mega-Tiny-devices

https://microchipsupport.force.com/s/article/8-bit-AVR-MCU-with-unique-serial-number

Thanks for the EEPROM and user row tips, I'll check it when I build the serial output interface for debugging.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.