Hi
I am not able to get COMPB to work. The reason for using COMPB instead of COMPA is the ability to trim the input value, that seems to be valid only for COMPB. The test program below is running on SmartTag. When the input on AUXIO5 goes above 1.2V it turns on respective led, and clear the event flag. When signal goes below 1.2V the led is turned off.
This works fine if I use COMPA (the code that I have comment out). But, when I use the same settings for COMPB, the flag is never turned off.
What am I doing wrong here?
Regards Arne
-------------------------------
PIN_Config myLedPinTable[] = { Board_LED1 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_DRVSTR_MAX, Board_LED2 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX, PIN_TERMINATE }; PIN_Config myButtonPinTable[] = { Board_KEY_RIGHT | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_NEGEDGE, Board_KEY_LEFT | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_NEGEDGE, PIN_TERMINATE }; PIN_Config AnalogInputPins[] = { Board_DP0 | PIN_INPUT_DIS | PIN_GPIO_OUTPUT_DIS , PIN_TERMINATE }; int main(void) { /* Call board init functions */ Board_initGeneral(); // Open Analog Pins board_DP0PinHandle = PIN_open(&board_DP0PinState, AnalogInputPins); /* Open LED pins */ myLedPinHandle = PIN_open(&myLedPinState, myLedPinTable); if(!myLedPinHandle) { System_abort("Error initializing board LED pins\n"); } myButtonPinHandle = PIN_open(&myButtonPinState, myButtonPinTable); if(!myButtonPinHandle) { System_abort("Error initializing button pins\n"); } AUXWUCClockEnable(AUX_WUC_MODCLKEN0_SOC_M|AUX_WUC_MODCLKEN0_AUX_ADI4_M); //HapiSelectCompAInput(COMPA_IN_AUXIO5); //HapiSelectCompARef(COMPA_REF_VDD1P2V); //HWREGB(AUX_ADI4_BASE + ADI_4_AUX_O_COMP) = ADI_4_AUX_COMP_COMPA_EN; HapiSelectADCCompBInput(ADC_COMPB_IN_AUXIO5); HapiSelectCompBRef(COMPB_REF_VDD1P2V); HWREGB(AUX_ADI4_BASE + ADI_4_AUX_O_COMP) |= ADI_4_AUX_COMP_COMPB_EN; while (true) { int compAeventAux= HWREGB(AUX_EVCTL_BASE + AUX_EVCTL_O_EVSTAT0) & AUX_EVCTL_EVSTAT0_AUX_COMPA; int compBeventAux= HWREGB(AUX_EVCTL_BASE + AUX_EVCTL_O_EVSTAT0) & AUX_EVCTL_EVSTAT0_AUX_COMPB; if (compAeventAux > 0) { PIN_setOutputValue(myLedPinHandle, Board_LED1, 1); HWREGB(AUX_EVCTL_BASE + AUX_EVCTL_O_EVSTAT0) &= ~(AUX_EVCTL_EVSTAT0_AUX_COMPA); } else PIN_setOutputValue(myLedPinHandle, Board_LED1, 0); if (compBeventAux > 0) { PIN_setOutputValue(myLedPinHandle, Board_LED2, 1); HWREGB(AUX_EVCTL_BASE + AUX_EVCTL_O_EVSTAT0) &= ~(AUX_EVCTL_EVSTAT0_AUX_COMPB); } else { PIN_setOutputValue(myLedPinHandle, Board_LED2, 0); } } return (0); }