cancel
Showing results for 
Search instead for 
Did you mean: 

USB Superspeed Peripherals

AlNo_3504021
New Contributor

Hello,

I'm trying to create an application which starts a SPI DMA transfer of 200 bytes every time there is a positive edge on one of the GPIO pins. Right now, I am polling the pin using CyU3PGpioGetValue and starting the DMA transfer on the positive edge by calling CyU3PSpiSetBlockXfer. However, this does not provide the speed that I need for my application, and the RTOS thread manager interrupting the execution of my application thread occasionally causes the application to miss the edge. I tried configuring a GPIO interrupt handler using the Api provided in cyu3gpio.h, but was unable to get CyU3PSpiSetBlockXfer to run inside of the ISR, as it seems like some API calls cannot be called within an interrupt handler. Is there any way to directly set the DMA controller to read SPI data in on an interrupt, or to allow for running a SPI transfer inside an ISR?

Thank you for any insight.

0 Likes
1 Solution
abhinavg_21
Moderator
Moderator

Hi,

Yes that's correct api has many checks to do before toggling the GPIO pin. These checks took time but they are necessary for correct operation. If you are sure that you are toggling the right GPIO pin then go ahead and use register access.

-Regards

Abhinav

View solution in original post

0 Likes
5 Replies
VlKh_2251656
Contributor II

Hello.

Use

CyU3PDmaChannelSetWrapUp (&dmaBuffer);

0 Likes
abhinavg_21
Moderator
Moderator

Hi,

You can raise an event flag in the GPIO ISR and then poll that event in "for" loop. Most of the firmware examples that comes along with SDK package uses this technique.

Just search for event flags firmware examples.

-Regards

Abhinav

0 Likes
AlNo_3504021
New Contributor

I implemented an event for when the interrupt is triggered per your suggestion, which fixed the issue where I was missing busy pin edges. However it takes approximately 24 microseconds from the GPIO line going high to the SPI starting to clock out data using this methodology (as compared to 8 microseconds by polling), which is unfortunately too slow for my use case (needs to be 10 microseconds or less). Is there any way that you know of to reduce that time delay, or to manually set the ISR for GPIO interrupts, to avoid overhead from using the API calls.

Thanks

0 Likes
AlNo_3504021
New Contributor

Update: I was able to resolve the issue by polling the GPIO pin directly via register access instead of going through the API.

0 Likes
abhinavg_21
Moderator
Moderator

Hi,

Yes that's correct api has many checks to do before toggling the GPIO pin. These checks took time but they are necessary for correct operation. If you are sure that you are toggling the right GPIO pin then go ahead and use register access.

-Regards

Abhinav

View solution in original post

0 Likes