2016-12-09 08:12 AM
Hi,
After playing with the STM32F746G Discovery for a while I decided to get a Waveshare OPEN746I-C kit with a 7 inch LCD with capacitive touchscreen as I wanted a bigger screen and access to more of the pins.
I've got the LCD working using CubeMX to generate a system workbench project and copying the supplied example code into the project and adding the necessary include paths in the C/C++ Build Settings.
However I cannot get the touchscreen working, whilst debugging the code the GT811_init() doesn't seem to be responding to the I2C read requests.
When I import the example project into Keil however the touchscreen works fine so I don't think it's a hardware issue.
I've been through the keil code and cannot see any obvious reason why it works and the system workbench code does not...
Does anyone have this board and has got the touchscreen working in system workbench?
Any suggestions to where I might be going wrong would be greatly appreciated.
Thanks in advance
Alex
2016-12-09 12:01 PM
Have you tried to debug the code + checking whether in SystemWorkbench there is a communication on the touchscreen bus (I2C or SPI is used for touch, right?)?
Renegade
2016-12-10 02:10 AM
Thanks for your reply ST Renegade,
I've tried to debug the code and the I2C read requests READ_SDA() seem to timeout as it seems to be permanently held high (1). The touchscreen is I2C but I don't know how to monitor the I2C bus for communication in System Workbench though I suspect that there isn't any communication on the bus.
Is there an option in System Workbench to monitor this or some other software?
Kind regards
Alex
2016-12-10 04:53 AM
This is not a STM32-specific issue, rather, general C/microcontroller programming.
> ... the supplied example code
Who supplied this? TS_I2C.c contains a bitbanged I2C implementation, possibly the poorest one I've ever seen.
static void delay_us(uint32_t value)
{ uint32_t i; i = value * 250; while(i--);}Loop delay might (and will be) entirely optimized out by a half-decent compiler, unless the loop variable is tagged as volatile.
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
...SDA_IN() ... SDA_OUT() ...Not that it can't be get working in a simple I2C setting, but it's not how I2C is supposed to be working - it's based on open-collector (drain).
JW
2016-12-10 07:43 AM
Hi Jan,
Thank you for your reply and explanation, the example code was supplied by Waveshare who manufactured the board i'm using.
Sounds like it would probably be best if try and re-write the TS_I2C code and use ''proper'' I2C with the HAL driver.
Thanks once again for your help on this problem, it does partly explain why it works in keil but not in System Workbench.
Kind regards
Alex
2016-12-10 08:16 AM
> Sounds like it would probably be best if try and re-write the TS_I2C code and use ''proper'' I2C with the HAL driver.
It's not what I've said.
There are reasons for bit-banging - it works even if the sensor is connected to pins which don't have I2C connectivity, for example. Also, simple I2C is easier to bit-bang than to use the hardware I2C module. I don't HAL so won't comment on that part.
JW
2016-12-12 04:41 AM
Hi Jan,
Thanks for your input, I've done as you suggested and tagged the loop variable as volatile and the touchscreen now works.
Thank you again for your help on this problem.
Kind regards
Alex
2016-12-12 01:58 PM
Hi Alex,
Since you are using the Waveshare board with an 7' LCD, I would like to know if you were able to make working the complete STemWIN 1024 X 600 examples from Waveshare? I'm working on this and in some samples crashes completly and I do not see why. I imported the code from Keil to VisualGDB. Thank you if you answer.
2016-12-13 10:39 AM
Hi,
I haven't got the complete demo of the STemWin example working yet. It's next on my to do list, so will let you know if I can get it working.
Regards
Alex
2019-01-09 11:34 AM
Hi Alex, i'm working with same display than yours (provided by waveshare) and also had the same problem, the function GT811_Init() doesn't works.
However i've debug the program and when i step into this function, there is a function call printf ("version:%x\r\n", version); wich crash the program (Console of SystemWorkbench shows "Info : halted: PC: 0x08001c14").
So its seems that is a memory problem, then i commented this function call (printf) and touchscreen is working.
I can't see what loop variable did you declared as volatile. I really want to do it but i couldn't found any delay loop. What loop have you modified?
Many Thanks!!
Andy