USB VBUS connected interrupt ; self powered with sleep

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

cross mob
CoLy_3905441
Level 2
Level 2
5 replies posted 10 sign-ins First solution authored

I am trying to enable the VBUS pin as an interrupt to wake my device.  It is self powered and goes to sleep as required, but I want to wake it up when a USB cable is connected, rising edge on P13[2].  The PSOC 4200L TRM and the PSOC 4200L Registers TRM state for USB control: 

pg 210 "

Additionally, the GPIO_PRT13_INTR_CFG register can be configured to
generate PICU interrupt on the rising/falling edge of the
P13[2] pin. The GPIO_PRT13_INTR interrupt status register
can be read in the "GPIO Interrupt - All Port" interrupt to
know if any of the events on P13[2] triggered the interrupt.

"

pg 1454 "

11.1.121 GPIO_PRT13_INTR_CFG
Address = 0x40040D0C
Port interrupt configuration register

Bits      Name                 Description

5 : 4      EDGE2_SEL     Sets which edge will trigger an IRQ for pin 2.
                                            Default Value: 0

                                             0x1: RISING:
                                             Rising edge

11.1.122 GPIO_PRT13_INTR
Address = 0x40040D10
Port interrupt status register

Bits      Name                 Description

2           DATA2                 Interrupt pending on pin 2. Firmware writes 1 to clear the interrupt.
                                            Default Value: 0

"

but I don't understand how to manipulate the system registers to do this, and the autofill isn't pulling anything that makes sense to me to be able to do this. 

So, my question, predominantly, is what function or script do I need to use to change the GPIO_PRT13_INTR_CFG 5:4 bits to 0x1, and what is the function or script to use in my global interrupt to clear bit 2 of GPIO_PRT13_INTR? 

0 Likes
1 Solution
CoLy_3905441
Level 2
Level 2
5 replies posted 10 sign-ins First solution authored

 

I found the answer from;
PSoC™ 4 MCU – Using GPIO pins - pg 67
7.9 Configure GPIO interrupt settings with firmware

 

A separate define with the address makes the call easier, since the original define isn't behaving.  CY_SET_REG32(address, value) is then used to set the register.  Not sure if it's needed, but I read the original value with CY_GET_REG32(address) and then OR in the specific value.  

/*USB Port 13 defines*/
#define Port13_int_cfg  0x40040D0C
#define Port13_int           0x40040D10

/*Interrupt Start*/
CY_SET_REG32(Port13_int_cfg, CY_GET_REG32(Port13_int_cfg) | (0x1 << 4));

/*Interrupt Clear*/
CY_SET_REG32(Port13_int, CY_GET_REG32(Port13_int) | (0x1 << 2));

View solution in original post

0 Likes
1 Reply
CoLy_3905441
Level 2
Level 2
5 replies posted 10 sign-ins First solution authored

 

I found the answer from;
PSoC™ 4 MCU – Using GPIO pins - pg 67
7.9 Configure GPIO interrupt settings with firmware

 

A separate define with the address makes the call easier, since the original define isn't behaving.  CY_SET_REG32(address, value) is then used to set the register.  Not sure if it's needed, but I read the original value with CY_GET_REG32(address) and then OR in the specific value.  

/*USB Port 13 defines*/
#define Port13_int_cfg  0x40040D0C
#define Port13_int           0x40040D10

/*Interrupt Start*/
CY_SET_REG32(Port13_int_cfg, CY_GET_REG32(Port13_int_cfg) | (0x1 << 4));

/*Interrupt Clear*/
CY_SET_REG32(Port13_int, CY_GET_REG32(Port13_int) | (0x1 << 2));

0 Likes