- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am trying to port a NXP project to a Cypress Project. I have a Transmit data interrupt enable (LPSPI_IER_TDIE_MASK) that I am using in my NXP project. I enable and disable this interrupt and then service the interrupt and do some api calls. I need similar behavior in Cypress PSOC4. Is it possible?
Solved! Go to Solution.
- Tags:
- interrupts
- spi_tx_api
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I wish you had written that you are using PSoC 4100S Plus.
Anyway, I tried some, as I do not have access to PSoC 4100S Plus now, I'm just using PSoC Creator.
I Created a project for PSoC 4100S Plus and drag and drop a SPI (SCB) component.
Then I double clicked the SPI_1 component
There I selected "Master" in the "Mode" pull-down menu.
I also changed the name to "SPI"
Then I changed the tab to "SPI Advanced"
There, I changed Interrupt to "External"
And I checked Interrupt sources
TX FIFO empty and RX FIFO not empty.
(you can choose any combination as you like)
Then I added an Interrupt component from System > Interrupt
I double clicked the component and changed the name to isr_spi
For debug print I added an UART
I changed the name of UART_1 to "UART"
Then select Workspace Explorer > Pins
and select pins for each functions.
Using the pull-down menu in the Port field will show you usable candidate, so choose one from there for your board.
After you finish pin assignment, select "Generate Application"
Now drivers for the selected components were generated in the "Generated Source"
Please take a look at in SPI > SPI.h etc to see what kind of API and defines are provided.
In the SPI.h I could find SPI_ENABLE_INTR_TX() etc.
Then main.c seems to be like below.
(Note: I have not tested)
=====================
#include "project.h"
CY_ISR(my_spi_isr)
{
uint32_t intr_source ;
intr_source = SPI_GetMasterInterruptSource() ;
SPI_CLEAR_INTR_MASTER(intr_source) ;
// check bit of intr_source and decide what to do
}
int main(void)
{
CyGlobalIntEnable; /* Enable global interrupts. */
UART_Start() ;
isr_spi_StartEx(my_spi_isr) ;
SPI_Start() ;
/* Place your initialization/startup code here (e.g. MyInst_Start()) */
for(;;)
{
/* Place your application code here. */
}
}
=====================
moto
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
This sample is my SPI_TEST with schematic
When I open SPIM component by double clicking it, Configure dialog opens.
And in the left bottom, there is a [Datasheet] Button.
When I open the Datasheet, in the left pane, there is Application Programming Interface > Functions.
You can see all SPIM APIs, which includes,
SPIM_EnableTxInt()
SPIM_EnableRxInt()
SPIM_DisableTxInt()
SPIM_DisableRxInt()
SPIM_SetTxInterruptMode()
SPIM_SetRxInterruptMode()
etc.
Then each function's descriptions are provided
Note: The reason I started this explanation from schematic is that there is/are difference between SCB SPI and UDB SPI or between versions.
So, IMHO, you should refer to the datasheet of the component you are using.
moto
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am using a PSoC 4100S Plus Device. Why am I not able to find the SPI Master Component in the Component Catalog?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I wish you had written that you are using PSoC 4100S Plus.
Anyway, I tried some, as I do not have access to PSoC 4100S Plus now, I'm just using PSoC Creator.
I Created a project for PSoC 4100S Plus and drag and drop a SPI (SCB) component.
Then I double clicked the SPI_1 component
There I selected "Master" in the "Mode" pull-down menu.
I also changed the name to "SPI"
Then I changed the tab to "SPI Advanced"
There, I changed Interrupt to "External"
And I checked Interrupt sources
TX FIFO empty and RX FIFO not empty.
(you can choose any combination as you like)
Then I added an Interrupt component from System > Interrupt
I double clicked the component and changed the name to isr_spi
For debug print I added an UART
I changed the name of UART_1 to "UART"
Then select Workspace Explorer > Pins
and select pins for each functions.
Using the pull-down menu in the Port field will show you usable candidate, so choose one from there for your board.
After you finish pin assignment, select "Generate Application"
Now drivers for the selected components were generated in the "Generated Source"
Please take a look at in SPI > SPI.h etc to see what kind of API and defines are provided.
In the SPI.h I could find SPI_ENABLE_INTR_TX() etc.
Then main.c seems to be like below.
(Note: I have not tested)
=====================
#include "project.h"
CY_ISR(my_spi_isr)
{
uint32_t intr_source ;
intr_source = SPI_GetMasterInterruptSource() ;
SPI_CLEAR_INTR_MASTER(intr_source) ;
// check bit of intr_source and decide what to do
}
int main(void)
{
CyGlobalIntEnable; /* Enable global interrupts. */
UART_Start() ;
isr_spi_StartEx(my_spi_isr) ;
SPI_Start() ;
/* Place your initialization/startup code here (e.g. MyInst_Start()) */
for(;;)
{
/* Place your application code here. */
}
}
=====================
moto
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Is there a reason to use External Interrupts vs Internal Interrupts?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Usually, we don't need "External Interrupt" if we can go with the APIs provided.
But you asked "Tx Interrupt Enable" in the subject title, so I thought it was mandatory for you.
moto
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Even if I just enable Internal Interrupts (and do not enable the External Interrupts), I can still see the SPI_ENABLE_INTR_TX() option in the SPI.h file.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Yes, if all you need is enable and disable the interrupt, you don't need the external interrupt.
But if you want to handle/modify the ISR, it is pre-defined in the "Generated source".
And I prefer not to touch the generated source, so I use external interrupt(s).
moto
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I plan on using the SCB_SPI_UART_ISR_ExitCallback() function to handle the Interrupt. One more question - what source mask should I be using, if I want the interrupt on SPI_1_INTR_TX_EMPTY? Should I be just using - SPI_1_ENABLE_INTR_TX(SPI_1_INTR_TX_EMPTY); or I also need to enable those in the PSOC Creator?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I tried enabling the SPI_1_INTR_TX_EMPTY interrupt. But now what is happening is that the interrupt is constantly occurring. If I try to clear the interrupt or do anything inside the ISR, I am getting a debugging error with my J Link that says - cannot read register 15 while CPU is running.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Have you seen my response above?
In the ISR, I had
==================
intr_source = SPI_GetMasterInterruptSource() ;
SPI_CLEAR_INTR_MASTER(intr_source) ;
==================
I think that this intr_source holds all bit(s) caused by interrupt.
So if you clear SPI_1_INTR_TX_EMPTY bit, but there is/are still other bit(s) set,
they are the source of recurrent interrupt(s).
One brain-dead approach is clearing all of them at once, which I used...
==================
SPI_CLEAR_INTR_MASTER(intr_source) ;
==================
moto