Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

Input Capture

24 views
Skip to first unread message

Oliver Kan

unread,
Mar 4, 2020, 4:24:33 AM3/4/20
to uavdevboard
Hi Guys,

In the file radioIn.c , for input capture module 
why do i get those hash tags  (IC##x##CO##z = IC2VAL;) are those hashtags supposed to represent something if so what?
and on that note- REGTOK1 N what does that mean ?

#define REGTOK1 N
#define REGTOK2 N
#define IC1VAL 0x0081
#endif
#define IC2VAL 0 // SYNCSEL = 0x00: no sync, no trigger, rollover at 0xFFFF
#define _IC_INIT(x, y, z) \
{ \
IC##x##CO##z = IC2VAL; \
IC##x##CO##y = IC1VAL; \
_IC##x##IP = INT_PRI_IC; \
_IC##x##IF = 0; \
_IC##x##IE = 1; \
}
#define IC_INIT(x, y, z) _IC_INIT(x, y, z)

Cheers
Oliver

Peter Hollands

unread,
Mar 4, 2020, 7:12:37 AM3/4/20
to uavdevboard
Oliver,

The ##s puzzled me when I first saw them a few years back; I did not know that this form of macro substitution existed,

The ##'s are a form of C macro instruction.  An explanation is given here on this tutorial site.
They are used to reduce repetition of blocks of code in the C source code.

MPLAB-X (mine is at version 5.3) will show you the complete macro expansion (after processing all macros including ##s).
This is useful to confirm that the Macros are doing what you hope !
While in radioIn.c, place your cursor over a macro and right click to select "Navigate" / "View Macro Expansion".
(see screenshot enclosed).  This will then open a new window showing the whole of radioIn.c with all macros expanded.
I enclose a second screenshot, with the macros expanded for my setup of MatrixPilot for HILSIM with a model easystar.

I hope that helps.

Best wishes, Pete







--
--
---
You received this message because you are subscribed to the Google Groups "uavdevboard" group.
To unsubscribe from this group and stop receiving emails from it, send an email to uavdevboard...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/uavdevboard/ad5f7ca8-abc4-4b30-aa68-8fcbbd9acdf1%40googlegroups.com.
Screen Shot 2020-03-04 at 11.58.16.png
Screen Shot 2020-03-04 at 11.59.55.png
Reply all
Reply to author
Forward
0 new messages