SPI of UC3C2512, Why "selectChip" is a must?

Go To Last Post
2 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm using UC3C2512-SPI0 to drive MBI5040. MOSI, SCK, MISO and CS0 were used. But MBI5040 is not a standard SPI slave. Its LE, connected to CS0, is not a normal CS. This pin is used to set some command. So I set CS0 in GPIO mode.

I modified the example project code to suit for my board.

U8 sdata[4]={0x55,0xaa,0x00,0xff};
spi_master_init(AT45DBX_SPI_MODULE);
spi_master_setup_device(AT45DBX_SPI_MODULE, &AT45DBX_DEVICE1, 0,AT45DBX_SPI_MASTER_SPEED, 0);
spi_enable(AT45DBX_SPI_MODULE);
spi_write_packet(AT45DBX_SPI_MODULE, &sdata,4);

there is no clock wave and data on SCK & MOSI pin.
when I insert
at45dbx_spi_select_device(3); // whatever 0-3
before spi_write_packet, it works. I got the data on MOSI.

I can't understand this. Did anybody know why?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The SPI module can have 4 different configurations for each of the chip select lines.
When you activate a chip select in master mode the SPI module loads that configuration and then allows you to transmit data.
(see 26.7.3 in the datasheet)

It is not a problem and actually is a benefit in your situation, because you can configure different chip-selects to have different clockrates.
eg. when you are pushing your pixel data out of the micro you select a chip-select that has been configured with a high clock frequency, and when you want to read the results of the pixeltest you select a chip-select that has a slower clock frequency.

In your situation do not enable the NPCSx functions on the GPIO pins., this means that when you activate a chip-select line the SPI module will function normally but the NPCSx line will not actually drive an external pin.

If all you ever want to do is send pixel data to the LED driver then just do one chip select after configuring the SPI channel and chip select channel.