If I use it with a circuit that uses both SPI and I2C I have problems. In the below program the first three " GLCDPrint" statements work correctly. After they print on the GLCD screen, the screen turns white and stays white.
Subsequent " GLCDPrint" commands do not work. When I connect an oscilloscope to the SPI SCK (portD.7) and SPI DO (portC.7) ports I see clock and data pulses being sent whenever I press any of the switches.
Is GCB able to switch back and forth between I2C and SPI commands? If so what am I doing wrong?
'Chip Settings.
#chip18F4550,48
#configPLLDIV=1, CPUDIV=OSC1_PLL2, OSC=HSPLL_HS, LVP=OFF, MCLRE=ON
#include<glcd.h>
#defineHI2C_BAUD_RATE100
#defineHI2C_DATAPORTB.0
#defineHI2C_CLOCKPORTB.1
#defineMiniTFT_WRITEADDR188
#defineMiniTFT_READADDR189
#defineGLCD_TYPEGLCD_TYPE_ST7735R_160_80
#defineST7735TABCOLORST7735_GREENTAB'Pin mappings for SPI ST7735R
#defineGLCD_DCportE.2'Data/Command select Purple Wire
#defineGLCD_CSportB.2'CS Chip select White
#defineGLCD_RESETportC.6' Gray
#defineGLCD_DOportC.7'SPI SDO (MOSI) Blue
#defineGLCD_DIportC.7'SPI SDI (MISO) assume bi-directional DO/DI
#defineGLCD_SCKportD.7'SPI SCK Green
#defineRESET_Pin28
#defineCTRL_Reset0
#defineDirClr_GPIO3
#definePullenSet_GPIO11
#defineSet_FunctionReg5
#defineModule_Base_Address_GPIO1
#defineGPIO_BULK4
#defineModule_Base_Address_AD9
#defineModule_function_register_address_AD07
#defineModule_function_register_address_AD18DirHI2C_DATAinDirHI2C_CLOCKinHI2CModeMaster'The Mini TFT needs 4.1 VDC for the GLCD good display quality. PIC needs to run at 5 VDC.' It will work with 3.5 VDC but colors may blur.'GLCD screen has black background with the below on itGLCDCLSGLCDRotate(Landscape)GLCDPrint(4, 0, "Great", TFT_YELLOW)GLCDPrint(4, 10, "Cow", TFT_GREEN)GLCDPrint(4, 20, "Basic", TFT_WHITE); This Workswait2sDo_Again:
'GLCD screen goes white and stays white'Setup SAM-D09 chipHI2CStartHI2CSendMiniTFT_WRITEADDRHI2CSendModule_Base_Address_GPIOHI2CSendDirClr_GPIOHI2CSend211HI2CSend198HI2CSend207HI2CSend220HI2CStopHI2CStartHI2CSendMiniTFT_WRITEADDRHI2CSendModule_Base_Address_GPIOHI2CSendPullenSet_GPIOHI2CSend211HI2CSend198HI2CSend207HI2CSend220HI2CStopHI2CStartHI2CSendMiniTFT_WRITEADDRHI2CSendModule_Base_Address_GPIOHI2CSendSet_FunctionRegHI2CSend211HI2CSend198HI2CSend207HI2CSend220HI2CStop'Read Switch Data from SAM-D09HI2CStartHI2CSendMiniTFT_WRITEADDRHI2CSendModule_Base_Address_GPIOHI2CSendGPIO_BULKHI2CRestartHI2CSendMiniTFT_READADDRHI2CReceiveFourth_ByteHI2CReceiveThird_ByteHI2CReceiveButton_XYSHI2CReceiveButton_AB, NackHI2CStop'The below 7 lines do NOT work - there is only a white screen - No printing occursIfButton_XYS.1=0thenGLCDPrint(4, 10, "Button B", TFT_RED)IfButton_XYS.2=0thenGLCDPrint(4, 0, "Button A", TFT_YELLOW)IfButton_XYS.3=0thenGLCDPrint(4, 60, "SELECT", TFT_RED)IfButton_AB.2=0thenGLCDPrint(4, 20, "UP", TFT_RED)IfButton_AB.3=0thenGLCDPrint(4, 30, "LEFT", TFT_RED)IfButton_AB.4=0thenGLCDPrint(4, 40, "DOWN", TFT_RED)IfButton_AB.7=0thenGLCDPrint(4, 50, "RIGHT", TFT_RED)GotoDo_Again
Last edit: Anobium 2019-12-01
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Yes, HWI2C is working. In my original program there was more code and the "IF" statements were bigger. I changed them in the version I sent you to reduce the confusion. (the version I sent you has the same problem as the longer version)
Here is what was after the HI2C READ. (All of this worked except the "GLCDPrint" statements.
I figured out most of this problem. The GLCD_RESET does not go directly to the GLCD. It goes to Pin 7 of the ATSAMD09D14A-MU chip that is on the GLCD board. Pin 7 which is labeled TFT_RST is an active low. I changed the HI2CSend 207 to HI2CSend 206. This puts a low on pin 7.
Now all the switches cause a read out on the display EXCEPT Button B which causes the display to go white and stay white even when other buttons are pressed.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm using this GLCD: https://learn.adafruit.com/adafruit-mini-tft-featherwing
It is an ST7735R which uses SPI. When I use software with only SPI commands in it everything works great.
If I use it with a circuit that uses both SPI and I2C I have problems. In the below program the first three " GLCDPrint" statements work correctly. After they print on the GLCD screen, the screen turns white and stays white.
Subsequent " GLCDPrint" commands do not work. When I connect an oscilloscope to the SPI SCK (portD.7) and SPI DO (portC.7) ports I see clock and data pulses being sent whenever I press any of the switches.
Is GCB able to switch back and forth between I2C and SPI commands? If so what am I doing wrong?
Last edit: Anobium 2019-12-01
Is this using the new library I provided?
Please put the project in a ZIP. I will delete the .h posts. It will confuse readers.
I need the ST7735 (two files) also.
The code
Here
Have you confirmed the HWI2C works? Output the i2C discover to a serial terminal not the GLCD.
Did you check I2C discovery? First rule of I2C - is test with I2C discovery.
There is nothing obvious in the code. So, I would be check oit I2C discovery.
Yes, HWI2C is working. In my original program there was more code and the "IF" statements were bigger. I changed them in the version I sent you to reduce the confusion. (the version I sent you has the same problem as the longer version)
Here is what was after the HI2C READ. (All of this worked except the "GLCDPrint" statements.
I figured out most of this problem. The GLCD_RESET does not go directly to the GLCD. It goes to Pin 7 of the ATSAMD09D14A-MU chip that is on the GLCD board. Pin 7 which is labeled TFT_RST is an active low. I changed the HI2CSend 207 to HI2CSend 206. This puts a low on pin 7.
Now all the switches cause a read out on the display EXCEPT Button B which causes the display to go white and stay white even when other buttons are pressed.
It sounds like you are getting there.
:=)