- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am trying to use the SPI (SBC mode) with a PSoC 4 MCU and I have the SPI pins displayed and linked to SPI inputs and SPI outputs. I can toggle the SPI pins but as soon as I linked them to the SPI component I cannot control them at all.
Any ideas what am I missing ?
Solved! Go to Solution.
- Labels:
-
PSoC 4 MCU
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello.
Have a look at PSoC 4 GPIO app notes AN86439. See section Pin Routing. There, you'll see how a GPIO output pin has a mux sitting in front of it. Once SCB has been connected to GPIO thru the mux, you no longer have CPU GPIO write access unless you re-write the HSIOM mux selection. At least, that's how I understand it.
You could add your own mux to a GPIO output pin where one mux input is from the SCB/SPI output, and the other mux input is from a Control register component that you write to. To swing this mux, use another Control register component bit to make the selection. Just something to try. Of course, when swinging this mux (or the HSIOM mux), you'd have to ensure the SPI transaction has completed first.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @gabi_barcan,
Could you please elaborate
- on linking SPI inputs to SPI outputs and
- on linking the SPI pins to the SPI component?
Which PSoC 4 device are you using?
You may refer to the "SCB_SpiCommMaster" and "SCB_SpiCommSlave" code examples in PSoC Creator to better understand using the SPI component.
[To access code examples, go to File->Code Example-> select the device family and type "SPI" in the filter to get all the code examples related to SPI.]
Regards,
Nikhil
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @ncbs, Thanks a lot for replying, hopefully this is something easy.
I'm using CY8C4248BZI-L489.
When I have the SPI pins connected to GPIO pins like below I CANNOT toggle them between 0 and 1.
The following code does not have any effect on the output pins:
while(true)
{
SPI_SEL_Write(0);
SPI_CLK_Write(0);
SPI_MOSI_Write(0);
CyDelay(100);
SPI_SEL_Write(1);
SPI_CLK_Write(1);
SPI_MOSI_Write(1);
CyDelay(100);
}
All these output pins are defined like this:
If I have them disconnected, meaning no HW connection checked like this:
Then using the same code above I can toggle the output between 0 and 1 without any problems.
Would appreciate any help.
Gabi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @gabi_barcan,
The functionality of HW connection of a digital output pin dictates how the pin operates.
- When the HW connection is enabled, then the pin outputs the digital signal supplied by hardware components through the DSI.
- When the HW connection is disabled, then the output logic level is determined by CPU register or API writes. Since you are using software APIs to control the logic values, HW connection should not be used.
Best regards,
Nikhil
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
All right, fair enough. I removed the digital pins and just mapped the SPI's pins without having them displayed to the same HW output pins.
So the code looks like this:
int main(void)
{
CyGlobalIntEnable; /* Enable global interrupts. */
while(true)
{
SPIM_sclk_m_Write(0);
SPIM_ss0_m_Write(0);
SPIM_mosi_m_Write(0);
CyDelay(100);
SPIM_sclk_m_Write(1);
SPIM_ss0_m_Write(1);
SPIM_mosi_m_Write(1);
CyDelay(100);
}
Still the output on the pins is flat, no control. Any ideas why ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello.
Have a look at PSoC 4 GPIO app notes AN86439. See section Pin Routing. There, you'll see how a GPIO output pin has a mux sitting in front of it. Once SCB has been connected to GPIO thru the mux, you no longer have CPU GPIO write access unless you re-write the HSIOM mux selection. At least, that's how I understand it.
You could add your own mux to a GPIO output pin where one mux input is from the SCB/SPI output, and the other mux input is from a Control register component that you write to. To swing this mux, use another Control register component bit to make the selection. Just something to try. Of course, when swinging this mux (or the HSIOM mux), you'd have to ensure the SPI transaction has completed first.