How to generate multiple interrupts in PSOC5 ?

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

cross mob
naku_4018846
Level 1
Level 1

Hi Team,

I am using PSOC5 development board, My requirement is to read 40 pins status continuously, Which method is to best to read 40 pins status ?  The PSOC5 board support 40 interrupt ?  If supports how to create 40 interrupts ?

How to much time required to read 40 GPIO status ?   Please any one help on this issues .

Regards,

VV   

0 Likes
1 Solution
lock attach
Attachments are accessible only for community members.

Hi naveenkumar.p_4018846​,

As suggested by user_342122993​, there are different ways to achieve this., But it is better if you achieve this using interrupts as you won't waste CPU time by continuously polling. In the interrupt method, the you will check the Pin state only when there is a state change in the pins.

The easiest way is to assign 8 pins of the same port to a particular pin component. Please remember that one interrupt will be generated per port (ORed of all the individual pins of a port). We need to use the Pin_ClearInterrupt() API to clear the interrupt and this function will also return you which pin has triggered the interrupt and you can read the status of that port using the Pin_Read() API (Each bit will correspond to the on/off of that pin).

For this:

1. First drag and drop the pins components (digital input pin) to the Top Design:

2. In the Pins component window, disable HW connection. In the inputs tab, select interrupt type to both edges. (ie) This will generate an interrupt whenever the pin state changes from 1 to 0 or 0 to 1.

3.  Do this for all the 5 components.

4. Drag and drop the ISR component and choose derived in the Interrupt Type

pastedImage_2.png

5. You need to write 5 ISRs for the 5 port interrupts.

6. In each of the ISR, you have to clear the PinInterrupt and set a flag.

7. In your main(), you can check the pin status only when the flag is set.

I have attached a sample code for you to get started.

The execution time will depend on the CPU clock speed.

You can also to the following documents for your better understanding:

PSoC 5lp datasheet : http://www.cypress.com/files/psoc-5lp-cy8c58lp-family-datasheet-programmable-system-chip-psoc-datash...

PSoC 5LP Architecture TRM : https://www.cypress.com/file/123561/download

PSoC 5Lp regsiter TRm : http://www.cypress.com/files/psoc5lp-registers-trmpdf

Pins Component datasheet: https://www.cypress.com/file/133231/download

ISR component datasheet : https://www.cypress.com/file/130976/download

PSoC 5 LP GPIO - Application Note :https://www.cypress.com/file/45381/download

PSoC 5LP Interrupts - Application Note: https://www.cypress.com/file/44256/download

Code Examples: https://www.cypress.com/file/44251/download

Hope this helps! Please let us know in case you have further clarifications.

Regards,

Bragadeesh

Regards,
Bragadeesh

View solution in original post

3 Replies
odissey1
Level 9
Level 9
First comment on KBA 1000 replies posted 750 replies posted

navinkumar,

You didn't specify how you plan to read pins: (1) by continuously polling, (2) by using interrupts and waiting for change of state.

In any ways, it is faster to group pins by 8 and make them contiguous, so they can be read all 8 pins at once. This way you will have 5 ports of 8 pins each. Reading such port gives uint8 result, where each bit corresponding to a pin state.

If using interrupts, enable such (grouped) pin interrupt for each port (total 5 interrupts are needed), and read pins state same way as polling inside the ISR handler.

You can find both techniques used in the ButtonSw32 custom component:

ButtonSw32: button switch debouncer component

/odissey1

ButtonSw_basic_1b.png

Thanks for the reply,

Which method to use read 40 pins status continuously polling, interrupts or waiting for change of state and how much time taking to read 40 pins. I am new in controller side Please provide links for code.

0 Likes
lock attach
Attachments are accessible only for community members.

Hi naveenkumar.p_4018846​,

As suggested by user_342122993​, there are different ways to achieve this., But it is better if you achieve this using interrupts as you won't waste CPU time by continuously polling. In the interrupt method, the you will check the Pin state only when there is a state change in the pins.

The easiest way is to assign 8 pins of the same port to a particular pin component. Please remember that one interrupt will be generated per port (ORed of all the individual pins of a port). We need to use the Pin_ClearInterrupt() API to clear the interrupt and this function will also return you which pin has triggered the interrupt and you can read the status of that port using the Pin_Read() API (Each bit will correspond to the on/off of that pin).

For this:

1. First drag and drop the pins components (digital input pin) to the Top Design:

2. In the Pins component window, disable HW connection. In the inputs tab, select interrupt type to both edges. (ie) This will generate an interrupt whenever the pin state changes from 1 to 0 or 0 to 1.

3.  Do this for all the 5 components.

4. Drag and drop the ISR component and choose derived in the Interrupt Type

pastedImage_2.png

5. You need to write 5 ISRs for the 5 port interrupts.

6. In each of the ISR, you have to clear the PinInterrupt and set a flag.

7. In your main(), you can check the pin status only when the flag is set.

I have attached a sample code for you to get started.

The execution time will depend on the CPU clock speed.

You can also to the following documents for your better understanding:

PSoC 5lp datasheet : http://www.cypress.com/files/psoc-5lp-cy8c58lp-family-datasheet-programmable-system-chip-psoc-datash...

PSoC 5LP Architecture TRM : https://www.cypress.com/file/123561/download

PSoC 5Lp regsiter TRm : http://www.cypress.com/files/psoc5lp-registers-trmpdf

Pins Component datasheet: https://www.cypress.com/file/133231/download

ISR component datasheet : https://www.cypress.com/file/130976/download

PSoC 5 LP GPIO - Application Note :https://www.cypress.com/file/45381/download

PSoC 5LP Interrupts - Application Note: https://www.cypress.com/file/44256/download

Code Examples: https://www.cypress.com/file/44251/download

Hope this helps! Please let us know in case you have further clarifications.

Regards,

Bragadeesh

Regards,
Bragadeesh