2
\$\begingroup\$

I have code that works using Arduino.

Because I wanted to size down the project, I replaced it with an Attiny841.

Process:

I soldered the 841 on an adapter and checked all pins using a multimeter for cold joints.

Then I connected the pins using this schematic from http://elecrab.com, but with a cap for RESET in addition:

enter image description here

I used the online Arduino environment to burn the ArduinoISP sketch to my Arduino.

Then I used the offline Arduino program, using ATTinyCore as such:

enter image description here

I burned the bootloader and it did so succesfully.

I then copy-pasted my own sketch in the offline environment and uploaded it, which also worked without a single error.

(For some weird reason I cannot burn the ArduinoISP using the offline program, hence the two-step method.)

Sketch:

I left my sketch unaltered, except for the selected pins which became:

#define BEAM_One 2
#define BEAM_Two 3  

#define LED_Install 4
#define BUTTON_Install 5 

#define AT_Mode 6
#define POWER_On 7

#define LED_Occupied 10

Basically, I thought, 841 physical pins 11 and 12 are TX/RX and 2 to 4 are special cases, so I can simply select pins 5 to 10 and 13 for I/O.

I then choose the above pins, using the pin mapping in the ATTinyCore documentation:

enter image description here

ATTinyCore already preconfigures PWM, so it can be used without any extra steps or coding, I read somewhere.

Physical pins 5 and 6 allow for attachInterrupt(), see PCINT10 and PCINT7 on PB2 and PA7.

Result:

I connected some LEDs at the 841's output pins.

Some don't react, which might be due to a cold joint.

However, others do react but not in the expected way.

The LED connected to 841 pin 10, or pin 7 in the Arduino code, should go HIGH, then LOW, then HIGH with noticeable delays. In reality, it is HIGH and stays that way.

The attachInterrupt() functions are something else still. I think I just figured out that I am trying to use INT on PB2 and PA7, but it only exists on PB1 contrary to Arduino. I can use PB2 and PA7, but those are PCINT, that change ports and only use CHANGE (not RISING or FALLING). I hope to fix this specific issue by using this library: https://github.com/NicoHood/PinChangeInterrupt.

Does anyone have a clue what the issue might be with the pins not reacting as expected?

Thank you for reading my small novel.

\$\endgroup\$
2
  • \$\begingroup\$ Before burning codes like interrupts involved, did you try to implement a simple switch and led circuit or a serial communication project and able to prove that your whole setup you crafted out is 100% right ? \$\endgroup\$
    – Mitu Raj
    Commented Aug 30, 2019 at 18:17
  • \$\begingroup\$ In my code there is a blinking LED also on a designated pin (setup has a certain power on and off routine to get to AT mode of a Bluetooth module). That's the standard example always used. I don't see why that wouldn't be good for testing. I mentioned it in my post. Programming chips on breakout boards with Arduino is also cumbersome. \$\endgroup\$ Commented Aug 30, 2019 at 21:47

1 Answer 1

1
\$\begingroup\$

Solved. Pin mapping had to be counterclockwise, selected under Tools when burning the sketch with Arduino.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.