- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am interfacing SPI module of SPC560DL40L3 microcntroller with TLE75008 to drive 5 relays.may i get some source or sample code for same.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Please use the IPD Config Wizard from the Developer Center Launcher to get the SPI frame command corresponding to the register Selected at it's value.
The SPI Transmit API used in the microcontroller used by you should be such that it follows the SPI timing diagram mentioned in the TLD75008 datasheet.
1. falling edge of CSN should indicate the beginning of access.
2. Data sent out of microcontroller should be sent out at a falling edge of SCLK and data received should be sampled at the rising edge of SCLK.
3. Each access must be terminated by rising edge of CSN.
If PSoC 6 is the microcontroller is used, below code can be used to send SPI frames to SPIDER+:
//SPI Init.
#define spi_frequency 1000000
cy_rslt_t result = CY_RSLT_SUCCESS;
result = cyhal_spi_init(obj, spi_mosi, spi_miso, spi_clk, spi_ss, NULL ,
8, CYHAL_SPI_MODE_00_MSB, false);
if (result == CY_RSLT_SUCCESS){
result = cyhal_spi_set_frequency(obj, spi_frequency);
if(result == CY_RSLT_SUCCESS){
return OK;
}
else{
return INTF_ERROR;
}
}
else{
return INTF_ERROR;
}
//SPI transmission.
uint8_t tx_data[2] = 0xXXXX; //Frame command from IPD wizard
uint8_t rx_data[2];
uint8_t bytes = 2;
result = cyhal_spi_transfer(obj, tx_data, bytes, rx_data, bytes, 0x00);
if(result == CY_RSLT_SUCCESS){
return OK;
}
else{
return INTF_ERROR;
}
Best Regards,
AliAsgar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Please use the IPD Config Wizard from the Developer Center Launcher to get the SPI frame command corresponding to the register Selected at it's value.
The SPI Transmit API used in the microcontroller used by you should be such that it follows the SPI timing diagram mentioned in the TLD75008 datasheet.
1. falling edge of CSN should indicate the beginning of access.
2. Data sent out of microcontroller should be sent out at a falling edge of SCLK and data received should be sampled at the rising edge of SCLK.
3. Each access must be terminated by rising edge of CSN.
If PSoC 6 is the microcontroller is used, below code can be used to send SPI frames to SPIDER+:
//SPI Init.
#define spi_frequency 1000000
cy_rslt_t result = CY_RSLT_SUCCESS;
result = cyhal_spi_init(obj, spi_mosi, spi_miso, spi_clk, spi_ss, NULL ,
8, CYHAL_SPI_MODE_00_MSB, false);
if (result == CY_RSLT_SUCCESS){
result = cyhal_spi_set_frequency(obj, spi_frequency);
if(result == CY_RSLT_SUCCESS){
return OK;
}
else{
return INTF_ERROR;
}
}
else{
return INTF_ERROR;
}
//SPI transmission.
uint8_t tx_data[2] = 0xXXXX; //Frame command from IPD wizard
uint8_t rx_data[2];
uint8_t bytes = 2;
result = cyhal_spi_transfer(obj, tx_data, bytes, rx_data, bytes, 0x00);
if(result == CY_RSLT_SUCCESS){
return OK;
}
else{
return INTF_ERROR;
}
Best Regards,
AliAsgar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
i have sent 0x803f and recevied same from IC in recieve buffer. i am not able to understand what output will come on OUT0_LS to OUT6_LS to drive LED OR RELAY. WHEN one end of LED are connected to +12 volt. following is image. please revert for same.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Please refer to TLD75008 Datasheet page no 51.
Setting OUT.OUTn bit, should allow the current to flow through and thus turn ON the channel.
After power-up, ensure the IDLE pin is set to HIGH, then set HWCR.ACT bit to 1.
Followed by sending 0x8035. This should turn ON the channels when the devices are connected to Vcc. After this send a read diagnostic frame to read the diagnostic values of the 0x8035 frame.
Please share a logic analyser trace for the above test procedure.
Best Regards,
AliAsgar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
thansk aliasgar
i have turned "ON" all chaneels & my all relays are operating at one time. but now we have to operate these relays at different conditions. and different time. like- i have to turn on relay 1 it ON only when my temperature goes above 35 degree.
2nd relay will turn "ON" only when my MY ENGINE RPM is above 1000 rpm.
if i am sending frame at those condition to turn ON respective relays then data is overwritten.
please suggest somthing. following is my code in SPC5 IDE
spi_lld_init();
/* Starting driver for test, DSPI_0 I/O pins setup.*/
spi_lld_start(&SPID1,&spi_config_DATA_ICin);
pal_lld_setpad(PORT_C,idle);
if(temperatue >35)
{
txbuf[1] =0x8020; // turning ON channel 1-OUTL1
pal_lld_clearpad(PORT_A,PIN_GPIO4_CS0);
spi_lld_exchange(&SPID1, 2, txbuf, rxbuf);
pal_lld_setpad(PORT_A,PIN_GPIO4_CS0);
}
else
{
txbuf[1] =0x8000; // turning ON channel 1-OUTL1
pal_lld_clearpad(PORT_A,PIN_GPIO4_CS0);
spi_lld_exchange(&SPID1, 2, txbuf, rxbuf);
pal_lld_setpad(PORT_A,PIN_GPIO4_CS0);
}
if(RPM >1000)
{
txbuf[1] =0x8004; // turning ON channel 1-OUTL2
pal_lld_clearpad(PORT_A,PIN_GPIO4_CS0);
spi_lld_exchange(&SPID1, 2, txbuf, rxbuf);
pal_lld_setpad(PORT_A,PIN_GPIO4_CS0);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Writing a hard-coded value to the register (like, tx_buf[1] = 0x8004), will result in overwriting of value already written to the register.
Instead, first read the register content (OUT.OUTn). Then bit operation can be performed on the 16 bit number to either set/clear the particular bit according to the requirement.
The resulting value can be written back to the driver. This would help avoid overwriting of other channels.
Best Regards,
AliAsgar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
hi
when i am puttting read commnad as following
txbuf[1] = 0x8010;
pal_lld_clearpad(PORT_A,PIN_GPIO4_CS0);
spi_lld_exchange(&SPID1, 2, txbuf, rxbuf);
pal_lld_setpad(PORT_A,PIN_GPIO4_CS0);
// READ COMMAND 0x4010//0x4002
spi_lld_send(&SPID1, 2, 0x4002);
spi_lld_receive(&SPID1, 2, rxbuf);
spi_lld_stop(&SPID1);
then my UART stops working
you please correct my previous code. how i apply read operation sothat my uart wont affect.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
hi ,
thansk aliasgar
how i implement this in my code. becuase i need both condition at same time, and we have only one register to turn on -off channelss.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I cannot make sense of the APIs you are using, could you explain me that.
SPI communication should not affect the UART communication.
Best Regards,
AliAsgar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
hi
thatw was hardwrae issue. now my all relays are operating as per the requirement. i have used switch statement for different conditions for txbuf[1] and applied bit operation.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Glad to hear that the issue is resolved.
Best Regards,
AliAsgar