|
Post by wphrwm on Nov 30, 2017 19:49:16 GMT
I am using Arduino pin 52 with IRQ enabled to detect an IR signal. I want to use the "Fast_digitalRead" macro to detect the state of the pin. My program fails to compile with the following error.
C:\Program Files (x86)\Arduino\hardware\aurduino_Dx/aurix/variants/tc275/Variant.h:511:36: error: 'D52_IN' was not declared in this scope
#define Fast_digitalRead(port) (D##port##_IN)
Is pin 52 not defined for fast read or do I need to do something? Thanks for any help
|
|
|
Post by Admin on Dec 1, 2017 8:33:25 GMT
Pin52 is connected to two TC275 pins on the ShieldBuddy. For the Fast_digitalRead() you need to specify which port pin on the TC275 you want to use.
#define D50A_IN P21_IN.B.P2 #define D51A_IN P13_IN.B.P3 #define D52A_IN P15_IN.B.P8 #define D53A_IN P20_IN.B.P10
#define D50B_IN P33_IN.B.P4 #define D51B_IN P02_IN.B.P8 #define D52B_IN P33_IN.B.P5 #define D53B_IN P11_IN.B.P12
To use Port 15.8 you need:
Port = Fast_digitalRead(52A);
To use Port 33.5 you need:
Port = Fast_digitalRead(52B);
|
|
|
Post by wphrwm on Dec 1, 2017 14:38:59 GMT
Thanks very much for that. What about IRQs? I seem to be detecting transitions (FALLING) when I use 52 in attach IRQs although I do seem to be detecting more transitions than expected! Should I use 52A?
|
|
|
Post by Admin on Dec 5, 2017 9:24:35 GMT
No, the attachInterrupt() function is not affected by the dual pin connections to pin52. The interrupt function will detect edges that are only a few hundred nanoseconds apart so any noise around the switching point could generate a lot of interrupts. I would suggest calling detachInterrupt(52) at the start of the service routine to stop subsequent calls to the interrupt from noise. At the end of the interrupt, you could then re-enable it with attachInterrupt(52). It might be a good idea to put a check in to make sure the pin is stable and in the expected state before re-attaching it!
|
|