NPCS lines for SPI on UC3

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

Hi,
Reading the UC3B datasheet they have 4 dedicated chip select lines NPCS0...NPCS3 for the SPI interface. What is the point of this, why not use any old GPIO for chip select? Is this supposed to be some special high speed selection? The datasheet suggest tying these NPCS lines to a decoder, but that just seems rediculous to me:

page 184 of UC3B datasheet:
"The user can program the SPI to operate with up to 15 peripherals by decoding the four Chip
Select lines, NPCS0 to NPCS3 with an external logic"

Marcus

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

The SPI master will automatically generate the chip select, why would you rather do it in software using GPIO?

Hardware is faster, more reliable and takes less CPU resources than bitbang (software) routines.

When using the 15 chip select mode, the SPI hardware outputs a binary code (0001, 0010, 0011 ...) instead of one of four. By using a binary to (1:15) decoder chip you can have up to 15 peripherals instead of just 4.

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

Ok, I see, so its just an automatic chip select. No, that is pretty neat, its just every other chip I've used requires you to do it manually so that's what I'm used to. Its just one extra line of code and if I have 5 or 6 different SPI devices, it would be rather annoying to have to add a decoder when I can just run some extra gpio lines instead.

Thanks,
Marcus

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

Also, by having automatic dedicated chip select lines allows running the whole setup via DMA which gives you the capabilty of crazy fast I/O with no lines of code.

Letting the smoke out since 1978