umesh 1 Posted December 13, 2015 Share Posted December 13, 2015 hi i am getting the error as Average_New.cpp: In function 'void setup()':Average_New.cpp:9:35: error: expected primary-expression before 'int' the code is as follows: void setup(){Serial.begin(9600);pinMode(GREEN_LED, OUTPUT);pinMode(RED_LED, OUTPUT);pinMode(PUSH2, INPUT_PULLUP);attachInterrupt(PUSH2, calibrate(int maxvalue), FALLING);} void calibrate(int maxValue){ if(maxValue<threshold) maxValue=threshold;} how to solve this problem?? what is mean by primary expression? Quote Link to post Share on other sites
L.R.A 78 Posted December 13, 2015 Share Posted December 13, 2015 simple:attachInterrupt(PUSH2, calibrate(int maxvalue), FALLING); /\ why do you have a function prototype here? it should just be "calibrate" Quote Link to post Share on other sites
umesh 1 Posted December 13, 2015 Author Share Posted December 13, 2015 if i put only function name: attachInterrupt(PUSH2, calibrate, FALLING); then it is showing this error: Average_New.cpp: In function 'void setup()':Average_New.cpp:9:43: error: invalid conversion from 'void (*)(int)' to 'void (*)()' [-fpermissive]C:\ti\energia-0101E0016-windows\energia-0101E0016\hardware\msp430\cores\msp430/Energia.h:212:6: error: initializing argument 2 of 'void attachInterrupt(uint8_t, void (*)(), int)' [-fpermissive] Quote Link to post Share on other sites
Rei Vilo 695 Posted December 13, 2015 Share Posted December 13, 2015 Functions for interrupts should be void function(void). No parameters allowed. L.R.A 1 Quote Link to post Share on other sites
umesh 1 Posted December 13, 2015 Author Share Posted December 13, 2015 if i put only void function(void) still it is getting error as Average_New.cpp: In function 'void setup()':Average_New.cpp:9:35: error: expected primary-expression before void Quote Link to post Share on other sites
igor 163 Posted December 13, 2015 Share Posted December 13, 2015 if i put only void function(void) still it is getting error as Where did you make the function take a void argument? Need to do in function definition, just leave function name in call. void calibrate(void) { if(maxValue<threshold) maxValue=threshold; } umesh 1 Quote Link to post Share on other sites
Rei Vilo 695 Posted December 13, 2015 Share Posted December 13, 2015 Help yourself: http://energia.nu/reference/attachinterrupt umesh 1 Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.