Attiny 212 badArg("Digital pin is constant, but not a valid pin");

i am trying to program attiny 212 with arduinouno but my sketch has some problems

const uint8_t czujnikPin = 3;  
const uint8_t przyciskPin = 6; 
const uint8_t port1Pin = 1;

int x;

void setup() {
  pinMode(3, INPUT);    
  pinMode(6, INPUT);  
  pinMode(1, OUTPUT);     
 
}

void loop() {
 
  
  if (digitalRead(czujnikPin) == HIGH) {
   
    x = 1;
  }
 

  if (digitalRead(przyciskPin) == HIGH) {
    
    x = 0;
  }
 
 if (x == 1) {
  digitalWrite(port1Pin, HIGH);
} else {
  digitalWrite(port1Pin, LOW);
}
}

there is code
and the error
In function 'check_valid_digital_pin',
inlined from 'pinMode' at C:\Users\tomek\AppData\Local\Arduino15\packages\megaTinyCore\hardware\megaavr\2.6.10\cores\megatinycore\wiring_digital.c:42:3,
inlined from 'setup' at C:\Users\tomek\Documents\Arduino\sketch_dec26a\sketch_dec26a.ino:10:10,
inlined from 'main' at C:\Users\tomek\AppData\Local\Arduino15\packages\megaTinyCore\hardware\megaavr\2.6.10\cores\megatinycore\main.cpp:54:8:
C:\Users\tomek\AppData\Local\Arduino15\packages\megaTinyCore\hardware\megaavr\2.6.10\cores\megatinycore\Arduino.h:879:7: error: call to 'badArg' declared with attribute error:
badArg("Digital pin is constant, but not a valid pin");
^
In function 'check_valid_digital_pin',
inlined from 'digitalRead' at C:\Users\tomek\AppData\Local\Arduino15\packages\megaTinyCore\hardware\megaavr\2.6.10\cores\megatinycore\wiring_digital.c:352:3,
inlined from 'loop' at C:\Users\tomek\Documents\Arduino\sketch_dec26a\sketch_dec26a.ino:24:18,
inlined from 'main' at C:\Users\tomek\AppData\Local\Arduino15\packages\megaTinyCore\hardware\megaavr\2.6.10\cores\megatinycore\main.cpp:56:9:
C:\Users\tomek\AppData\Local\Arduino15\packages\megaTinyCore\hardware\megaavr\2.6.10\cores\megatinycore\Arduino.h:879:7: error: call to 'badArg' declared with attribute error:
badArg("Digital pin is constant, but not a valid pin");
^
lto-wrapper.exe: fatal error: C:\Users\tomek\AppData\Local\Arduino15\packages\DxCore\tools\avr-gcc\7.3.0-atmel3.6.1-azduino7b1/bin/avr-gcc returned 1 exit status
compilation terminated.
c:/users/tomek/appdata/local/arduino15/packages/dxcore/tools/avr-gcc/7.3.0-atmel3.6.1-azduino7b1/bin/../lib/gcc/avr/7.3.0/../../../../avr/bin/ld.exe: error: lto-wrapper failed
collect2.exe: error: ld returned 1 exit status

exit status 1

Compilation error: exit status 1

Which pin is pin 6?

pin6 is pa6

PA6 is pin 0

Arduino pin numbers, in general, has nothing to do with chip pin numbers.

If you prefer to refer pins by their names like PA6 - you can use long pin names directly in your code:

okay code is working but many times when i am trying to upload it i have error

Sketch uses 462 bytes (22%) of program storage space. Maximum is 2048 bytes.
Global variables use 12 bytes (9%) of dynamic memory, leaving 116 bytes for local variables. Maximum is 128 bytes.
avrdude: jtagmkII_initialize(): Cannot locate "flash" and "boot" memories in description
avrdude: jtagmkII_program_enable(): bad response to enter progmode command: RSP_ILLEGAL_MCU_STATE
avrdude: jtagmkII_program_enable(): bad response to enter progmode command: RSP_ILLEGAL_MCU_STATE
avrdude: jtagmkII_read_byte(): bad response to read memory command: RSP_ILLEGAL_MCU_STATE
avr_read(): error reading address 0x0000
read operation not supported for memory "signature"
avrdude: error reading signature data for part "ATtiny212", rc=-2
avrdude: error reading signature data, rc=-2
avrdude: jtagmkII_program_disable(): bad response to leave progmode command: RSP_NO_TARGET_POWER
Failed programming: uploading error: exit status 1

How are you trying to program the Attiny212 via your UNO?

With "Arduino as ISP" ?

that's not going to work, as you need a UPDI programmer.

no no i am using jtag2updii and one time sketch was uploaded right, but after many tries most of time i have this error
sometimes there is another error
RSP_NO_TARGET_POWER
*i connected pin reset and gnd with capacitor on arduino uno and iam using 1k resistor beetwen pd6(uno pin) and updi pin on my pcb

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