SPI EXAMPLE

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

SPI EXAMPLE

3,566 Views
Nadia
Contributor III

HELLO!!
I have problems loading an SPI example, the spi_polling_b2b_transfer_master.c
It always has errors and I don't understand why, I am trying to do something similar with a DAC that works by SPI, I try to send an array of data as it is done in the example, but it doesn't work either.

If someone knows why the example doesn't work correctly, and how to send an array of data from the SPI, please let me know.

Thank you very much.
Best regards.

0 Kudos
Reply
7 Replies

3,542 Views
Nadia
Contributor III

I'm using the MCP4821 DAC, which I don't know if it might be incompatible or something.

0 Kudos
Reply

3,547 Views
frank_m
Senior Contributor III

> If someone knows why the example doesn't work correctly, and how to send an array of data from the SPI, please let me know.

SPI is a loosely defined protocol, with variants in e.g. clock polarity, trigger edge, and clock speed.

Your SPI master setup (MCU) need to match the requirements of the slave (DAC).

As suggested, take a logic analyser or scope and compare the signal form with the DAC datasheet.

And I hope you are aware that SPI is a synchronous protocol, but the slave response is deferred by at least one transfer cycle.

3,522 Views
Nadia
Contributor III

@frank_m WHAT FUNCTION SHOULD I USE TO TRANSMIT IN SPI WITHOUT NEEDING A RESPONSE? How can I set the clock to 16 pulses?

0 Kudos
Reply

3,515 Views
frank_m
Senior Contributor III

> WHAT FUNCTION SHOULD I USE TO TRANSMIT IN SPI WITHOUT NEEDING A RESPONSE?

I suppose you mean, without regarding the response.

You can either read it out to clear any interrupt/FIFO flag, and discard the value. Or configure the SPI FIFO to ignore RX data (FIFOWR, bit 22 = RXIGNORE).

The standard SPI interface contains a write (MOSI) and a read (MISO) line, from the master's view. Each clock pulse cycles one bit out on MOSI and one bit in on MISO simultaneously.

> How can I set the clock to 16 pulses?

The same SPI config register (FIFOWR) contains a length field, bits 27..24. A 16-bit transfer corresponds to a value 0xF for this field. 

Check the user manual, SPI section for details. (UM10912, sect. 26.6.14 for the LPX546xx),  I don't know the associated SDK functions, I haven't used them yet.

0 Kudos
Reply

3,560 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Nadia,

To help you please provide more information:

1) Which chip?

2) Does it have issue when directly run demo?

3) What about the detail issue about doesn't work? 

4) You can use Logic measure signal .

 

BR

Alice

 

0 Kudos
Reply

3,552 Views
Nadia
Contributor III

@Alice_YangLPC54628,When I run the demo with the test board I get the messages that there has been an error, the printf's of the program that say that there has been an error I mean.

 

I am not modifying the demo.

0 Kudos
Reply

3,539 Views
Nadia
Contributor III

I'm using the MCP4821 DAC, I don't know if it might be incompatible.

0 Kudos
Reply