Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I2C LCD ... nothing on the screen.... #538

Open
iso14000 opened this issue Jan 24, 2025 · 2 comments
Open

I2C LCD ... nothing on the screen.... #538

iso14000 opened this issue Jan 24, 2025 · 2 comments
Labels
question Further information is requested

Comments

@iso14000
Copy link

Variant

TRANSPOTTER

Control type

FOC

Control mode

Voltage

Description

HI,

I'm actually trying to connect a LCD 14x2 with the well known I2C interface to generate timings.

so , YES I can see the I2C protocol working with my scope :
and YES the lines of the LCD panels are toggling.
E line behaves like a clock indeed and I can see data on D4 to D8
I can see also RW and RS lines toggling

but nothing on the screen, and Yes I did check the contrast.

is somebody already connect a LCD screen like that to the board?

regards

@iso14000 iso14000 added the question Further information is requested label Jan 24, 2025
@iso14000
Copy link
Author

I started to dig in the code...

It has been modified and a lot of lines are commented out ; more interesting is that

LCD_RESULT LCD_GetBusyFlag(LCD_PCF8574_HandleTypeDef* handle, uint8_t* flag) {

never really read the busy flag....

I suppose then , that time spend by executing this dummy function was enough for the HD77480 to process its instructions internally....

@iso14000
Copy link
Author

iso14000 commented Jan 26, 2025

OKay , I finally make it with LCD.. it works for me know.

Keeping in mind that LCD initialisation is very critical, because ate the very begining, interface must be switched to 4bit width.

I added some delay , without inpact on the main loop because it is done on the beginning and only once.
see bellow

`
LCD_RESULT LCD_Init(LCD_PCF8574_HandleTypeDef* handle) {
handle->D = 1; // D is for display On=1 Off=0
handle->B = 0; // B is for blinking character
handle->C = 0;// C is cursor display
if (handle->type == TYPE0) {
handle->pins = PCF8574_Type0Pins;
} else {
//handle->errorCallback(LCD_ERROR);
return LCD_ERROR; // no type of subinterface was specified
}
if (PCF8574_Init(&handle->pcf8574) != PCF8574_OK) {
//handle->errorCallback(LCD_ERROR);
return LCD_ERROR;
}

HAL_Delay(50); //may be usefull FSI
/*while(1){
LCD_StateWriteBit(handle, 0, LCD_PIN_RS);
LCD_StateWriteBit(handle, 1, LCD_PIN_RS); //FSI just to find this f..king pin
 }*/
LCD_StateWriteBit(handle, 0, LCD_PIN_RS);  //initialization
LCD_StateWriteBit(handle, 0, LCD_PIN_RW);
LCD_StateWriteBit(handle, 0, LCD_PIN_E);

LCD_WriteToDataBus(handle, 3);

LCD_StateWriteBit(handle, 1, LCD_PIN_E);
HAL_Delay(1);
LCD_StateWriteBit(handle, 0, LCD_PIN_E);
HAL_Delay(6);

LCD_WriteToDataBus(handle, 3);

LCD_StateWriteBit(handle, 1, LCD_PIN_E);
HAL_Delay(1);
LCD_StateWriteBit(handle, 0, LCD_PIN_E);
HAL_Delay(6);

LCD_WriteToDataBus(handle, 3);

LCD_StateWriteBit(handle, 1, LCD_PIN_E);
HAL_Delay(1);
LCD_StateWriteBit(handle, 0, LCD_PIN_E);
HAL_Delay(6);

LCD_WriteToDataBus(handle, 2);

LCD_StateWriteBit(handle, 1, LCD_PIN_E);
HAL_Delay(1);
LCD_StateWriteBit(handle, 0, LCD_PIN_E);
HAL_Delay(6);

uint8_t cmd = 0;
cmd = cmd | (handle->NUMBER_OF_LINES << 3); //N=1 for 2 lines
cmd = cmd | (1 << 5); //DL is 1 and F=0 means 5x8 dot , so selected interface is  4bits 
//interface so here data8 is 0010 1000 

LCD_WriteCMD(handle, cmd);	// setting interface

cmd = 0;
cmd = cmd | (1 << 3);
cmd = cmd | (handle->C << 1);
cmd = cmd | handle->B; //interface so here data8 is 0000 1000 


LCD_WriteCMD(handle, cmd);	// setting display/cursor , display Off, cursor Off

LCD_ClearDisplay(handle);

LCD_EntryModeSet(handle, DIRECTION_INCREMENT, SHIFT_NO);

LCD_DisplayON(handle);

LCD_StateLEDControl(handle, 1);	// LED power on

return LCD_OK;

}
`
HAL_Delay(6) was previously set to 1.

afterward I added another delay into the following fonction :
`
LCD_RESULT LCD_WriteCMD(LCD_PCF8574_HandleTypeDef* handle, uint8_t cmd) {
if (!LCDerrorFlag) {
LCD_StateWriteBit(handle, 0, LCD_PIN_E);
LCD_StateWriteBit(handle, 0, LCD_PIN_RS);

	LCD_WriteToDataBus(handle, cmd >> 4); //MSB first
	LCD_StateWriteBit(handle, 1, LCD_PIN_E);
	LCD_StateWriteBit(handle, 0, LCD_PIN_E);
	//HAL_Delay(6); //FSI
	LCD_WriteToDataBus(handle, cmd);
	LCD_StateWriteBit(handle, 1, LCD_PIN_E);
	LCD_StateWriteBit(handle, 0, LCD_PIN_E);
	HAL_Delay(1);//FSI
	LCD_WaitForBusyFlag(handle);

	return LCD_OK;
} return LCD_ERROR;

`

FSI is my trigramm , I can keep track of all my mods by a textual research

withtout "HAL_Delay(1);//FSI" in the code above, my LCD don't work.

it is critical for main loop because this function is called everytime a command is sent to HD44780 .

hopping it will help....

regards

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant