Other Parts Discussed in Thread: TMS320F28027
Hi, First,
I apologize for my English, which is not very good.,
I'm
having a little problem in my project. I am using a device called
MAX3420 to make SPI/USB bridge, because I need speed in data
transmission. Until then everything was ok.
The MAX3420 works as follows: the first byte of each transfer is a
command byte (indicates the resgister to be accessed and will be read or
written), and the next bytes are the data to be write (or read). So I'm
operating my SPI using MISO and MOSI (for sending and receiving data),
the SCLK (clock) and SPISTE.
The SPISTE is used as a "chip select" that will be set low while
reading or writing operation is being performed. However, each data
sending via SPI (SPITXBUFF) when the pin 19 is configured as SPISTE,
this operation is now performed automatically.
Here is my problem: I need to put on low level "chip select" and
keep it at a low level until the SPI send all data (command byte and
subsequent data).
This is the function I created to perform this operation:
----------------------------------------------------------------------------------------------------
void wreg(char reg, char dat),
{ GpioDataRegs.GPACLEAR.bit.GPIO19 = 1; // Clear SS (SPISTE)
spi_xmit((reg+2)<<8); // Send the register addres and the write byte (+2)
spi_xmit(dat<<8); // Send data
GpioDataRegs.GPASET.bit.GPIO19 = 1; // Set SS (SPISTE),
}
----------------------------------------------------------------------------------------------------,
The pin GPIO19 is configured as I/O, and the SPI Delay Transmit is 0.
Using
a logic analyzer, it was verified that the bits are being placed
correctly in MOSI and the SCLK is also ok. The SS is set low at the
correct time (1us before starting the transfer), however, he returns to
high (disabling the slave device) before the end of the data transfer.
When I set the pin 19 directly as SPISTE and not GPIO, SS enables
and disables correctly but the data that appear on MOSI is incorrect.
The first 8 bits appear correctly, however the last 8 bits only appear
as zeros.
Importantly, SPI configured to work with 8bits: SpiaRegs.SPICCR.bit.SPICHAR = 0x0007
I am working with TMS320F28027
I appreciate the help!
Thanks