Cyc8kit-041-41xx Code

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Marcus_Hellen
Level 3
Level 3
10 replies posted 10 questions asked 10 likes given

Hello Everyone,

I do not know how the following code is not working correctly. The thing is that it should be LED should ON regarding into if(CapSense_IsAnyWidgetActive()) statement but code cannot go into if(CapSense_IsAnyWidgetActive()) statement. I checked with LED_Write() function. 

"if(CapSense_NOT_BUSY == CapSense_IsBusy()){
CapSense_ProcessAllWidgets();
LED_Write(LED_OFF); " working correctly. I see that LED is turn off but I said before that code cannot go into if(CapSense_IsAnyWidgetActive()) function. How can be possible? What is wrong?

 

Code:

int main(void)
{
CyGlobalIntEnable; /* Enable global interrupts. */

/* Place your initialization/startup code here (e.g. MyInst_Start()) */
CapSense_Start();
CapSense_ScanAllWidgets();
CapSense_RunTuner();

for(;;)
{
/* Place your application code here. */
if(CapSense_NOT_BUSY == CapSense_IsBusy()){
CapSense_ProcessAllWidgets();
LED_Write(LED_OFF);
if(CapSense_IsAnyWidgetActive()){

LED_Write(LED_ON);

0 Likes
1 Solution
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Hi,

I wonder if you are calling CapSense_ScanAllWidgets()

at the end of the  if (CapSense_NOT_BUSY ...) block?

something like ...

if (CapSense_NOT_BUSY == CapSense_IsBusy()) {
	CapSense_ProcessAllWidgets() ;
	LED_Write(LED_OFF) ;
	if (CapSense_IsAnyWidgetActive()) {
		LED_Write(LED_ON) ;
		/* ... */
	}
	/* ... */
	CapSense_ScanAllWidgets() ; // <-------
}

 

 moto

View solution in original post

0 Likes
4 Replies
lock attach
Attachments are accessible only for community members.
Vison_Zhang
Moderator
Moderator
Moderator
First comment on KBA 750 replies posted 250 sign-ins

Please follow the "quick start" section of CapSense component datasheet.

0 Likes

Thank you for your quick respond. Yes, I checked the section however I did not see anything wrong with my code... How my code is not working correctly?

0 Likes
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Hi,

I wonder if you are calling CapSense_ScanAllWidgets()

at the end of the  if (CapSense_NOT_BUSY ...) block?

something like ...

if (CapSense_NOT_BUSY == CapSense_IsBusy()) {
	CapSense_ProcessAllWidgets() ;
	LED_Write(LED_OFF) ;
	if (CapSense_IsAnyWidgetActive()) {
		LED_Write(LED_ON) ;
		/* ... */
	}
	/* ... */
	CapSense_ScanAllWidgets() ; // <-------
}

 

 moto

0 Likes

Thank you Moto. You are right... I forgot to add. When I add the statement you mentioned it did work 🙂