In the abbreviated code below (just to initialize everything and test the GLCD), I have commented out the calls in applicationInit() and the test text appears on the GLCD. If I uncomment any one of the weather_ routines to set parameters, the GLCD is blank.
I'm sure it has something to do with an MCU pin (or pins) being asked to do double duty, but from everything I've read, the Click board pins are different from the GLCD pins. Can someone show me my error?
Code: Select all
' *
' * Project name:
' GLCD_Test (Demonstration of the GLCD library routines)
' * Copyright:
' (c) Mikroelektronika, 2019.
' * Revision History:
' - Initial release
' * Description:
' This is a simple demonstration of the GLCD library routines:
' - Init and Clear (pattern fill)
' - Image display
' - Basic geometry - lines, circles, boxes and rectangles
' - Text display and handling
' * Test configuration:
' MCU: PIC18F47K42
' http://ww1.microchip.com/downloads/en/DeviceDoc/PIC18LF26-27-45-46-47-55-56-57K42-Data-Sheet-40001919E.pdf
' dev.board: easypic v8lcd
' https://www.mikroe.com/easypic-v8
' Oscillator: HS-PLL 32.0000 MHz, 8.0000 MHz Crystal
' Ext. Modules: GLCD 128x64, KS108/107 controller
' https://www.mikroe.com/glcd-128x64?search_query=GLCD+128x64&results=10
' SW: mikroBasic PRO for PIC
' http://www.mikroe.com/mikrobasic/pic/
' * Notes:
' - Turn on GLCD backlight switch and PWM switch SW6.1 and SW6.2 (board specific)
' - Make sure that CAN switch is toggled to up position (GPIO position) RB3/RB2 (board specific)
' *
program Glcd_Test
' Declarations section
include Click_Weather_types
include Click_Weather_config
dim
temperature as float
humidity as float
pressure as float
logText as char[50]
degCel as char[4]
' Glcd module connections
dim GLCD_DataPort as byte at PORTD
dim GLCD_CS1 as sbit at LATB5_bit
GLCD_CS2 as sbit at LATB4_bit
GLCD_RS as sbit at LATB2_bit
GLCD_RW as sbit at LATB3_bit
GLCD_EN as sbit at LATC1_bit
GLCD_RST as sbit at LATA3_bit
dim GLCD_CS1_Direction as sbit at TRISB5_bit
GLCD_CS2_Direction as sbit at TRISB4_bit
GLCD_RS_Direction as sbit at TRISB2_bit
GLCD_RW_Direction as sbit at TRISB3_bit
GLCD_EN_Direction as sbit at TRISC1_bit
GLCD_RST_Direction as sbit at TRISA3_bit
' End of Glcd module connections
dim counter as byte
someText as char[18]
sub procedure systemInit()
mikrobus_gpioInit(_MIKROBUS1, _MIKROBUS_CS_PIN, _GPIO_OUTPUT)
mikrobus_i2cInit(_MIKROBUS1, @_WEATHER_I2C_CFG[0])
end sub
sub procedure Delay2S() ' 2 seconds delay sub function
Delay_ms(2000)
end sub
sub procedure applicationInit()
dim STAT as uint8_t
weather_i2cDriverInit(T_WEATHER_P(@_MIKROBUS1_GPIO), T_WEATHER_P(@_MIKROBUS1_I2C), STAT)
Delay_ms(100)
'weather_setStandbyTime(_WEATHER_STANDBY_TIME_1_MS)
'weather_setFilterCoefficient(_WEATHER_FILTER_COEFF_16)
'weather_setOversamplingTemperature(_WEATHER_OVERSAMP_2X)
'weather_setOversamplingHumidity(_WEATHER_OVERSAMP_1X)
'weather_setOversamplingPressure(_WEATHER_OVERSAMP_16X)
'weather_setOversamplingMode(_WEATHER_NORMAL_MODE)
Delay_ms(100)
degCel[0] = 32
degCel[1] = 176
degCel[2] = 67
degCel[3] = 0
end sub
main:
ANSELB = 0 ' Configure PORTB pins as digital
ANSELC = 0
ANSELD = 0 ' Configure PORTD pins as digital
systemInit()
applicationInit()
Glcd_Init() ' Initialize Glcd
Glcd_Fill(0x00) ' Clear Glcd
while TRUE
Glcd_Fill(0x00) ' Fill GLCD
Glcd_Set_Font(@font5x7, 5, 7, 32) ' Change font
Glcd_Write_Text("TEXT DEMO", 0, 0, 2) ' Write string
Delay2S()
'Glcd_Fill(0x00) ' Clear Glcd
'Glcd_Set_Font(@Character8x7, 8, 7, 32) ' Change font
someText = "8x7 Font"
Glcd_Write_Text(someText, 0, 2, 2) ' Write string
Delay_ms(200)
'Glcd_Set_Font(@System3x5, 3, 5, 32) ' Change font
someText = "3X5 CAPITALS ONLY"
Glcd_Write_Text(someText, 0, 4, 2) ' Write string
Delay_ms(200)
'Glcd_Set_Font(@font5x7, 5, 7, 32) ' Change font
someText = "5x7 Font"
Glcd_Write_Text(someText, 0, 6, 2) ' Write string
Delay_ms(200)
'Glcd_Set_Font(@FontSystem5x7_v2, 5, 7, 32) ' Change font
someText = "5x7 Font (v2)"
Glcd_Write_Text(someText, 0, 8, 2) ' Write string
Delay_ms(2000)
wend
end.