Mikroelektronika MIKROE-738 Datenbogen
504
mikoC PRO for PIC32
MikroElektronika
Library Example
Default Pin Configuration
Use
SPI_Lcd_Init
for default pin settings (see the first figure below).
Copy Code To Clipboard
char *text = "mikroElektronika";
// Port Expander module connections
sbit SPExpanderRST at LATD8_bit;
sbit SPExpanderCS at LATD9_bit;
sbit SPExpanderRST_Direction at TRISD8_bit;
sbit SPExpanderCS_Direction at TRISD9_bit;
// End Port Expander module connections
char i;
// Loop variable
void Move_Delay() {
// Function used for text moving
Delay_ms(
500
);
// You can change the moving speed here
}
void main() {
void main() {
CHECON
= 0x32;
AD1PCFG
= 0xFFFF; // Configure AN pins as digital
// If Port Expander Library uses SPI2 module
// Initialize SPI module used with PortExpander
SPI2_Init_Advanced(_SPI_MASTER,_SPI_8_BIT, 4, _SPI_SS_DISABLE,_SPI_DATA_SAMPLE_MIDDLE,_
SPI_CLK_IDLE_LOW,_SPI_ACTIVE_2_IDLE);
SPI_Lcd_Config(
0
);
// Initialize Lcd over SPI interface
SPI_Lcd_Cmd(_LCD_CLEAR);
// Clear display
SPI_Lcd_Cmd(_LCD_CURSOR_OFF);
// Turn cursor off
SPI_Lcd_Out(
1,6
, "mikroE");
// Print text to Lcd, 1st row, 6th column
SPI_Lcd_Chr_CP('!');
// Append '!'
SPI_Lcd_Out(
2,1
, text);
// Print text to Lcd, 2nd row, 1st column
// SPI_Lcd_Out(3,1,"mikroE"); // For Lcd with more than two rows
// SPI_Lcd_Out(4,15,"mikroE"); // For Lcd with more than two rows
Delay_ms(
2000
);
// Moving text
for(i=
0
; i<4; i++) {
// Move text to the right 4 times
Spi_Lcd_Cmd(_LCD_SHIFT_RIGHT);
Move_Delay();
}
while(
while(
1
) {
// Endless loop
for(i=
0
; i<
8
; i++) {
// Move text to the left 7 times
Spi_Lcd_Cmd(_LCD_SHIFT_LEFT);
Move_Delay();
}
for(i=
for(i=
0
; i<
8
; i++) {
// Move text to the right 7 times
Spi_Lcd_Cmd(_LCD_SHIFT_RIGHT);
Move_Delay();
}
}
}
}