|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Did you know...
|
Serial Wombat SPI Master Channel ModeThe SPI Master Channel Mode allows the user to attach slave SPI devices to the Serial Wombat. The pin to which this mode is assigned becomes the chip select line for the device. The Serial Wombat's hardware-enhanced SPI pins ( 18, 23, and 24 ) are used for the SCL, SDI and SDO lines of the SPI bus. Polarity, clock rate, and sampling point are configurable, within the limitations of the hardware capabilities of the 18F4620 microcontroller upon which the Serial Wombat is based. The pin configured as the chip select may not be the SCL, SDI, or SDO pin, but can be a non-I/O pin such as power or chip reset, if no chip select is required. The SPI Master Channel Mode uses Queues for the output / input which goes to / from the SPI bus. The steps for using this mode are as follows:
Message format:The SPI Master Channel Mode uses three channel mode configuration commands. The first two are for initial configuration of the mode. The third lets the Wombat know that the Transmit queue is loaded and ready to go, triggering the SPI transaction.
The second message provides additional configuration information, and should be sent after the 200 message:
The third message is used to trigger a SPI transaction. This is used each time a new set of data is loaded into the Transmit queue for transmission.
Example 1: Using a SPI based Digital to Analog converter.The Microchip MCP4821 is a SPI based 12-bit Digital to Analog converter. Reading through the datasheet, we can determine the following about this part:
Assume we've connected the CS line to Wombat pin 20. Commands: 128 0x0000 0x0002 0 ; Create a 2 byte queue at address 0x0000 200 20 26 0 1 0 0 0x55 ; Configure Pin 20 to be SPI master chip select
; Sampling point doesn't matter
; Transmit on active to idle
; Idle is Low
; Chip select is active low
201 20 26 0 0x0000 0xFFFF 0x55 0x55 ; Configure Pin 20 to be SPI master chip select
; Clock at 8Mhz (fastest we can go)
; Transmit buffer is at 0x0000
; No Receive buffer
131 0x0000 2 0x1800 0x55 0x55 ; Place two bytes in queue at address 0x0000: 0x18 and 0x00
; (Will cause D/A to go to 50%, or 2.048V)
202 20 26 0x55 0x55 0x55 0x55 0x55 ; Cause Queue to be sent out over SPI 131 0x0000 2 0x1C00 0x55 0x55 ; Place two bytes in queue at address 0x0000: 0x1C and 0x00
; (Will cause D/A to go to 75%)
202 20 26 0x55 0x55 0x55 0x55 0x55 ; Cause Queue to be sent out over SPI 131 0x0000 2 0x1o00 0x55 0x55 ; Place two bytes in queue at address 0x0000: 0x10 and 0x00
; (Will cause D/A to go to 0%)
202 20 26 0x55 0x55 0x55 0x55 0x55 ; Cause Queue to be sent out over SPI |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Copyright Wombat Interface Products, 2005-2008. All Rights Reserved.