问题描述
我有这个:
static void ButtonDebounce(void)
{
static uint16_t debounceCounter = 0;
// Check if only one S3 or s4 button pressed since if I have bouncing several
// interrupts will occur and will result on several resets on board.
if ((BUTTON_Ispressed( BUTTON_S3 ) == true) || (BUTTON_Ispressed( BUTTON_S4 ) == true)){
if(debounceCounter == 0)
{
LED_Toggle( LED_D4 ); //Led blinks when Btn3 or Btns4 is pressed.
if (BUTTON_Ispressed( BUTTON_S3 ) == true){
//__asm__ volatile ("reset"); // soft-reset not recommended.
RCONBITS.SWDTEN = 1; // Software Enable of WDT => page 99 PIC24FJ1024GA610/GB610 documentation
// #pragma config WDT = ON. => Page 43 - MPLAB_XC16_C_Compiler_Users_Guide.pdf
// Enable WDT. The safer way to implement
// reset on the system is via WDT since this
// timer is resetting the whole
// board and not only the microcontroller.
while(1){} // Just wait for wdt to reset the system.
}
else if (BUTTON_Ispressed( BUTTON_S4 ) == true){
printf("Avg Temp = %4f\r\n Avg Hmdt = %4f\r\n Min Temp = %4d\r\n Max Temp = %4d\r\n Min Hmdt = %4d\r\n Max Hmdt = %4d\r\n",calculateAvgTemp(),calculateAvgHumidity(),calculateMinTemp(),calcuateMaxTemp(),calculateMinHumidity(),calcuateMaxHumidity());
}
}
debounceCounter = BUTTON_DEBOUCE_TIME_MS;
} else{
if(debounceCounter != 0)
{
debounceCounter--;
}
}
}
并得到:
main.c: In function 'ButtonDebounce':
main.c:123:25: error: expected identifier or '(' before '.' token
make[2]: *** [build/default/debug/main.o] Error 255
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2
nbproject/Makefile-default.mk:135: recipe for target 'build/default/debug/main.o' Failed
有什么建议吗?我试图按照文档中的说明实现所有内容:PIC24FJ1024GB610,我有很多年参与 pic 的工作,然后我从事了组装工作。问题出在 RCONBITS.SWDTEN = 1;
解决方法
将 RCONBITS.SWDTEN = 1;
更改为 RCONbits.SWDTEN = 1;
这可能会解决错误。