Quantcast
Channel: Forums - Recent Threads
Viewing all articles
Browse latest Browse all 262198

CC2530 falling edge interrupts strange behaviour

$
0
0

Hi,

I designed a board with CC2530 but having problem with falling/raising edge interrupts. Below I attached shortened code I used for testing and PCB design for an overview.

Interrupts are detected properly (most of the times but not always...) on both failing & raising edge when I press button soldered to P1.4 pin. However problems I am faicing is that when I touch GDN of the board (no matter where) with screwdriver it raises an interrupt (and while debugging on IAR all interrupt flags for P1 are set [0xFF]). This is very strange because after reset all ports are set up as output pins with pull up resistor but chip behaves unexpectedly like all P1 pins would be set up as inputs. Please, note that P1.4 button is activated by low level. 

Then, I noticed that CS pin of CC-Debugger is also connected to GND and I thought that it may be somehow connected with this behavior. So I tested the same piece of code for P2.0 pin (which according to the design is floating pin not connected to anything). And here as well... touching pin or GND with screwdriver activates an interrupt routine. (screwdriver was isolated from my body so it shouldn't be seen as GND and shouldn't raise falling edge interrupt, right?) 

What is even more strange after touching GND with any metal object all chip registers seem to become corrupted and IAR shows warning message: "Warning:Flash page 0 is locked and was not written to." and only unplugging CC-Debugger helps in this case so debugging of code can be continued. 

Does anyone have an idea what is wrong with our design/chip/code/etc.? Maybe this is sth that is expected and touching GND with anything can cause such problems?

Second question, in this design below: Does P1.4 need to be configured as tri-state or a normal input pin with internal pull-up resistor is fine? Is external pull-up resistor required in this case?

Thank you in advance for any help!

Best regards,
Lukasz Spas

Test code (for P1.4 pin):

#include <ioCC2530.h>

int main(void)
{
	P1SEL &= ~(1 << 4);    /* Set pin function to GPIO */
	P1DIR &= ~(1 << 4);    /* Set pin direction to Input */
	P1INP &= ~(1 << 4);	 /* Pullup/Pulldown instead of 3-state*/
	P2INP &= ~(1 << 6);	 /* Pullup on P1 instead of Pulldown */

	/* For falling edge, the bit must be set. */
	PICTL |= (1 << 2);

	/* Interrupt configuration:
	* - Enable interrupt generation at the port
	* - Enable CPU interrupt
	* - Clear any pending interrupt
	*/
	P1IEN |= (1 << 4);
	IEN2 |= (1 << 4);
	P1IFG = ~(1 << 4);

	EA = 1;

	while (1); // endless loop
}

#pragma vector=P1INT_VECTOR
__interrupt void halKeyPort1Isr(void)
{
	if (P1IFG & (1 << 4))
	{
		PICTL ^= (1 << 2); // Reverse edges detection to detect debounce
	}

	/*
	Clear the CPU interrupt flag for Port_1
	PxIFG has to be cleared before PxIF
	*/
	P1IFG = 0;
	P1IF = 0;
}

Simplified PCB Design:

(Please visit the site to view this file)


Viewing all articles
Browse latest Browse all 262198

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>