tinygo icon indicating copy to clipboard operation
tinygo copied to clipboard

avr: adding pin change interrupt handling to atmega328p

Open mrbell321 opened this issue 3 years ago • 1 comments
trafficstars

This is what I've come up with for AVR pin change interrupts.

mrbell321 avatar Sep 07 '22 22:09 mrbell321

I created a ticket for this work too: https://github.com/tinygo-org/tinygo/issues/3145 Not sure what the official ticket/git tagging mechanism is...

mrbell321 avatar Sep 08 '22 16:09 mrbell321

So @mrbell321 has this been tested on real hardware?

deadprogram avatar Sep 29 '22 09:09 deadprogram

I’m on macOS not Linux and I’ve been through the process a couple times. Not the only one having the issue either. There’s a slack thread.

On Thu, Sep 29, 2022 at 3:46 AM Ron Evans @.***> wrote:

@.**** commented on this pull request.

In src/machine/machine_atmega328p.go https://github.com/tinygo-org/tinygo/pull/3139#discussion_r983253188:

  •   PCMSK_REG = avr.PCMSK0
    
  • PCIE = avr.PCICR_PCIE0
    
  • PIN0 = PD0
    
  • PCINT = 1 << (pin - PIN0)
    
  • IRQ = avr.IRQ_PCINT0
    

Please see https://tinygo.org/getting-started/install/linux/#avr-eg-arduino-uno for the install requirements for AVR on Linux.

— Reply to this email directly, view it on GitHub https://github.com/tinygo-org/tinygo/pull/3139#discussion_r983253188, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAH52U5JQDUWPUVU5NHFUELWAVJOPANCNFSM6AAAAAAQHFEHMI . You are receiving this because you authored the thread.Message ID: @.***>

mrbell321 avatar Sep 29 '22 13:09 mrbell321

The early version, yes, but there have been changes I cannot test yet due to the above toolchain issues.

On Thu, Sep 29, 2022 at 4:42 AM Ron Evans @.***> wrote:

So @mrbell321 https://github.com/mrbell321 has this been tested on real hardware?

— Reply to this email directly, view it on GitHub https://github.com/tinygo-org/tinygo/pull/3139#issuecomment-1262032197, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAH52UYQXYYNG5NF5676IHTWAVQALANCNFSM6AAAAAAQHFEHMI . You are receiving this because you were mentioned.Message ID: @.***>

mrbell321 avatar Sep 29 '22 13:09 mrbell321

I've tried this change on a custom board with atmega328p chip.

Interrupt fires. Can't use irremote driver directly though, since this change misses PinRising and PinFalling states. I'm not exactly sure how, but handling of the state shall be possible to add, see for example https://www.avrfreaks.net/s/topic/a5C3l000000URmcEAG/t120592

ysoldak avatar Jun 07 '23 17:06 ysoldak

This can be closed now, @deadprogram ?

ysoldak avatar Jul 31 '23 09:07 ysoldak

@ysoldak yes.

@mrbell321 thank you for pointing the way on the implementation. Now closing this PR.

deadprogram avatar Jul 31 '23 09:07 deadprogram