dbuezas / lgt8fx

Board Package for Logic Green LGT8F328P LGT8F328D and LGT8F88D
362 stars 87 forks source link

How to use PCINT4? #178

Closed brother-yan closed 1 year ago

brother-yan commented 3 years ago

Since mega328p doesn't have this interrupt vector. How to use this interrupt in lgt8f328p? Thanks!

LaZsolt commented 3 years ago

I never use pin change interrupts. I found few examples for you: https://thewanderingengineer.com/2014/08/11/arduino-pin-change-interrupts/ https://www.teachmemicro.com/arduino-interrupt-tutorial/ https://github.com/NicoHood/PinChangeInterrupt I think it is quite simple. You need only change the names of ports or interrupt vector names.

dwillmore commented 1 year ago

@brother-yan what was your results with LaZsolt's suggestions?

LaZsolt commented 1 year ago

Since the @brother-yan hasn't loggen in the Github for two years, I close this issue.

jayzakk commented 1 year ago

That's perfectly fine, I added them in #40

brother-yan commented 1 year ago

@dwillmore I don't use LGT MCU since 2020. I have a solution: just add a *.S file in your sketch folder

添加文件:IVT_extended.S

#include <avr/io.h>

#ifdef __AVR_MEGA__
  #define XJMP jmp
  #define XCALL call
#else
  #define XJMP rjmp
  #define XCALL rcall
#endif

.section .vectors, "ax", @progbits
  .weak __vector_26
  ;.set __vector_26, __bad_interrupt
  XJMP  __vector_26
  .weak __vector_27
  ;.set __vector_27, __bad_interrupt
  XJMP  __vector_27
  .weak __vector_28
  ;.set __vector_28, __bad_interrupt
  XJMP  __vector_28
  .weak __vector_29
  ;.set __vector_29, __bad_interrupt
  XJMP  __vector_29

即可

LaZsolt commented 1 year ago

Thank you for the answer.-