The code demonstrates how to use SPI library functions. Assumed HW configura-
tion is: max7219 (chip select pin) connected to RC1, and SDO, SDI, SCK pins are
connected to corresponding pins of max7219.
MikroElektronika:
Development
tools
-
Books
-
Compilers
26 9
page
mikroC
- C Compiler for Microchip PIC microcontrollers
mikroC
making it simple...
Library Example
//------------------- Function Declarations
void max7219_init1();
//-------------------------------- F.D. end
char i;
void main() {
Spi_Init();
// Standard configuration
TRISC &= 0xFD;
max7219_init1();
// Initialize max7219
for (i = 1; i <= 8u; i++) {
PORTC &= 0xFD;
// Select max7219
Spi_Write(i);
// Send i to max7219 (digit place)
Spi_Write(8 - i);
// Send i to max7219 (digit)
PORTC |= 2;
// Deselect max7219
}
TRISB = 0;
PORTB = i;
}//~!