У меня есть это:
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;