hello ,
i started new project and need to communicate with bq76pl536 ic from tms570, is there any ready to use driver for this ic ?
i am run out of time that why need ready to use driver
thanks
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Mehmet,
You can use the HALCoGen tool to generate the SPI software according to the interface requirement of bq76pl536. You may need to first come up with the communication mechanism at the system level (what information to exchange, how often, etc) before working or the low level software.
Thanks and regards,
Zhaohong
Hi,
I use HalCoGen but I have some problems,
I want to adressing BQ76PL536, and I send spi functions tx_data which device_adress,register_adress,number of bytes,zero(until num of bytes) and CRC. I use this routine
spi_read_function(tx_data,rx_data){
spiSetData(spiREG1,0,tx_data);
spiTransfer(spiREG1,0);
while(!(spiIsTransferComplete(spiREG1,0))){};
spiGetData(spiREG1, 0, rx_tata); //use only read
}
spi_write_function(BROADCAST_ADDR, RESET_REG, BQ76PL536_RESET); //BQ76PL536 registers
spi_read_function(DISCOVERY_ADDR, DEVICE_STATUS_REG, 1, DISCARD_CRC, rx_data); // I read DEVICE_STATUS_REG=0x00
//Adress1
spi_write_function(DISCOVERY_ADDR, ADDRESS_CONTROL_REG, 0x01);
spi_read_function(0x01, ADDRESS_CONTROL_REG, 0x01, 0, rx_data);
//Adress2
spi_write_function(DISCOVERY_ADDR, ADDRESS_CONTROL_REG, 0x02);
spi_read_function(0x02, ADDRESS_CONTROL_REG, 0x01, 0, rx_data);
finaly I read again DEVICE_STATUS_REG=0x00 . Where is the proplem? Can you help me ?
Mehmet,
There are a couple of things you need to take care of.
(1) HSEL pin on Bq76PL536 needs to be tied low to enable host interface.
(2) SPI CS needs to stay low for the entire message. You need to control the CS_HOLD bit in SPI_DAT1 register during transmission. CS_HOLD bit should be high except for the last data. The SPI data size needs to be 8 bit as required by Bq76PL536.
(3)Communicating with Bq76PL536 requires SPI transmission and reception happens simultaneously. The HALCoGen funions you use will not work. Take a look at the spiTransmitAndReceive() function. You may need to write your own function because this function us polling method which blocks CPU to do other work during SPI transactions. I am also not sure if it can change CS_HOLD in run time.
To debug this issue, you need to use a oscilloscope to check all 4 SPI signals to see if meets the requirement of Bq76PL536.
Thanks and regards,
Zhaohong