As an example of the
operation of the SPI function of the CGMMSTICK1, this example
interfaces to a SPI potentiometer.
An MCP41100 SPI
potentiometer was selected from Microchip Technology. This is a 100k
potentiometer that can be adjusted in 256 steps from one end of the
dial to another.
PB0 and PA0 were
connected to 5V and ground respectively. PW0 is the 'wiper' and will
move in position between 0V and 5V under control of the CGMMSTICK1
via the commands sent through MMIDE.
The SPI serial lines
are all set as OC (open collector) with a pull up resistor of 10k
ohms.
The CS (chip select)
line of the digital pot is connected to I/O Pin 14, in open collector
mode (with 10k ohm pull up). It is active low. The data transfer
starts with this line high. The line is brought low, serial data is
transmitted, and the line returned high.
The SPI applet is used
to transmit two bytes to the digital pot.
Pins 11, 12, and 13 are
used to communicate with the digital pot. Note that this hardware
uses the 8-pin MCP41100, so there actually is no data read from the
digital pot.
The clock and data pins
are set to OC. The rate is L – low. The polarity for clock/data 1s
set to 3 - clock is active low, data is captured on the rising edge
and output on the falling edge.
The chip is selected
(CS low) and 11 is clocked to the chip. This is the command byte for
this chip. Then a value from 0 (0v) to 255 (5V) is clocked to the
chip before returning high. When the CS is high the pot switches to
the commanded setting.
Purchase a CGMMSTICK1 Download of Maximite Integrated Development Environment: MMIDE
No comments:
Post a Comment