我有一个电容式传感器、我要监控其活动、一旦有活动、我就要唤醒该器件并开始测量它、还有另一个传感器。 我需要使用 CapTIvate 来处理唤醒、然后使用其他软件来接管。
或者是否可以使用 CapTIvate 在0.5pF 分辨率下获得绝对电容读数? 这一点不太容易判断、因为坚持只使用 CapTIvate 可能会更方便吗?
如果无法或不适合为此起诉 CapTIvate、那么我很好奇进入和退出 CapTIvate 的最佳方式是什么?
到目前为止、解决方案使用回调来设置标志和关闭 CapTIvate。 不允许主循环进入 apphandler 或 sleep、禁用计时器似乎会有所帮助。 有没有其他或更好的方法可以做到这一点?
void main(void) { WDTCTL = WDTPW | WDTHOLD; BSP_configureMCU(); setHiZPins(); GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P6,GPIO_PIN0,GPIO_SECONDARY_MODULE_FUNCTION); MAP_CAPT_registerCallback(&wakeButton, &wakeup_CB); CAPT_appStart(); __bis_SR_register(GIE); while(1){ if(!g_userModeFlag){ CAPT_appHandler(); CAPT_appSleep(); }else{ GPIO_setAsInputPin(GPIO_PORT_P3, GPIO_PIN0); initPeripherals(); startMeasuring(); CAPT_powerOn(); while(ovf_count < 15 || angle_reading < MAX_ANGLE); g_userModeFlag = false; } } }
我看到了一个使用 CAPT_appHandler ()上的返回值的解决方案,而不是禁用 CapTIvate。 所以我想出了这样的问题。
while(1){ bool hadActivity = CAPT_appHandler(); if(hadActivity && !g_userModeFlag){ //First activity after sleep, so we need to init some stuff MAP_CAPT_stopTimer(); MAP_CAPT_clearTimer(); MAP_CAPT_powerOff(); g_userModeFlag = true; LED2_ON; //GPIO_setAsInputPin(GPIO_PORT_P3, GPIO_PIN0); //test to see if it helps with the circuit to put captivate pin in hi-z if(enableUART){ initUART(); } initComp(); initTimer(); startMeasuring(); }else if(!hadActivity){ // We sleeping, nothing special going on CAPT_appSleep(); //What is the state of P3.0 aka Cap0.0 here if we set it as input when starting user mode???? }else if(!hadActivity && g_userModeFlag){ //first inactivity after user mode so we need to de-init some stuff stopMeasuring(); g_userModeFlag = false; LED2_OFF; MAP_CAPT_powerOn(); MAP_CAPT_startTimer(); } }
我主要想寻找一种利用 CapTIvate 进行测量的方法、或在器件处于唤醒状态时避开它的方法。
谢谢!