Hardware Reference
In-Depth Information
void sendtomax (char c1, char c2, char c3, char c4)
{
char
temp;
PTM & 5 , BIT5;
/* enable SPI transfer to MAX6952 */
putcspi0(c1);
/* send c1 to MAX6952 */
putcspi0(c2);
/* send c2 to MAX6952 */
putcspi0(c3);
/* send c3 to MAX6952 */
putcspi0(c4);
/* send c4 to MAX6952 */
PTM | 5 BIT5;
/* load data from shift register to latch */
}
void openspi0(void)
{
SPI0BR 5 0x00; /* set baud rate to 12 MHz */
SPI0CR1 5 0x50; /* disable interrupt, set master mode, shift data on
rising edge, clock idle low */
SPI0CR2 5 0x02; /* disable mode fault, disable SPI in wait mode */
WOMS 5 0;
/* enable Port S pull-up */
}
Example 10.10
Modify the previous example to blink the display at a slow rate.
Solution: We need to change the setting of the configuration register and also send the space
character (0x20) to the four digits in plane P1. New data to be sent to the configuration registers
are as follows:
0x04, 0x19, 0x04, 0x19
The main program should be modified as follows:
void main (void)
{
openspi0();
DDRM | 5 BIT5;
// configure PM5 pin for output
sendtomax(0x01, 0xFF, 0x01, 0xFF);
sendtomax(0x02, 0xFF, 0x02, 0xFF);
sendtomax(0x03, 0x01, 0x03, 0x01);
sendtomax(0x04, 0x19, 0x04, 0x19);
// configuration register, blink at phase P1
sendtomax(0x07, 0x00, 0x07, 0x00);
// disable test
sendtomax(0x20, 0x54, 0x20, 0x20);
// value for digit 0 on plane P0
sendtomax(0x21, 0x45, 0x21, 0x55);
// value for digit 1
sendtomax(0x22, 0x43, 0x22, 0x53);
// value for digit 2
sendtomax(0x23, 0x45, 0x23, 0x4D);
// value for digit 3
sendtomax(0x40, 0x20, 0x40, 0x20);
// value for digit 0 on plane P1 (space)
sendtomax(0x41, 0x20, 0x41, 0x20);
// value for digit 1 “
sendtomax(0x42, 0x20, 0x42, 0x20);
// value for digit 2
sendtomax(0x43, 0x20, 0x43, 0x20);
// value for digit 3
}
 
Search WWH ::




Custom Search