HAL ErrorCode 4 with RW1063 I2C Screen
Hello,
I am coming to you because I have a rather difficult issue to identify.
I have a screen mounted on I2C that originally communicates with an Arduino board via its address 0x3C. I have verified that I can communicate with this address using my Nucleo 64 F401RE board.
However, when I look at the frames, I encounter information that doesn't match up. Worse, when I look at what HAL returns, I get a rather strange error that I would like to submit to you.
In order:
- I rely on the documentation of the screen RW1063
- I know the hardware is OK since it responds
- I know my initialization commands are OK since I can manipulate the screen
- HAL returns the error Name: ErrorCode / Details:4 / Default:4 / Decimal:4 / Hex:0x4 / Binary:100 / Octal:04
- The problem is not isolated to a specific part of the code, but I am scrutinizing a particular part of the code when I transmit data
Here is a piece of code in C:
/* USER CODE END Header */
/* Includes ------------------------------------------------------------------*/
#include "main.h"
#include "i2c.h"
#include "usart.h"
#include "gpio.h"
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
#include "stdio.h" // sprintf()
#include "stdbool.h" // boolean
/* USER CODE END Includes */
/* Private define ------------------------------------------------------------*/
/* USER CODE BEGIN PD */
#define DELAY_MAN 500
#define ADDRESSE_ECRAN 0x3C
#define NB_COLONNES 16
#define NB_LINES 2
/* USER CODE END PD */
/* USER CODE BEGIN PV */
/* USER CODE END PV */
/* Private function prototypes -----------------------------------------------*/
void SystemClock_Config(void);
/* USER CODE BEGIN PFP */
/* USER CODE END PFP */
/* Private user code ---------------------------------------------------------*/
/* USER CODE BEGIN 0 */
void RW1063_send_command(uint8_t command);
void RW1063_show_cursor();
void RW1063_hide_cursor();
void RW1063_blink_cursor();
void RW1063_no_blink_cursor();
/* USER CODE END 0 */
/**
* @brief The application entry point.
* @retval int
*/
int main(void)
{
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
/* MCU Configuration--------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* USER CODE BEGIN Init */
/* USER CODE END Init */
/* Configure the system clock */
SystemClock_Config();
/* USER CODE BEGIN SysInit */
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_I2C1_Init();
MX_USART2_UART_Init();
/* USER CODE BEGIN 2 */
RW1063_send_command(0x38); // 8-bit mode, 2 lines, 5x8 characters
HAL_Delay(1);
RW1063_send_command(0x0C); // Turn on the screen, disable cursor and blinking
HAL_Delay(1);
RW1063_send_command(0x01); // Clear the screen
HAL_Delay(10);
RW1063_send_command(0x06); // Move the cursor to the right after each character
HAL_Delay(1);
RW1063_show_cursor();
HAL_Delay(500);
RW1063_hide_cursor();
HAL_Delay(500);
RW1063_show_cursor();
RW1063_blink_cursor();
HAL_Delay(2000);
RW1063_no_blink_cursor();
HAL_Delay(500);
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
}
}
void RW1063_send_command(uint8_t command) {
HAL_StatusTypeDef res;
uint16_t size_buff = 2;
uint8_t tbl_command[size_buff];
tbl_command[0] = 0x00;
tbl_command[1] = command;
res = HAL_I2C_Master_Transmit(&hi2c1, ADDRESSE_ECRAN << 1, tbl_command, size_buff, HAL_MAX_DELAY);
if(res != HAL_OK) {
HAL_GPIO_WritePin(LD2_GPIO_Port, LD2_Pin, GPIO_PIN_SET);
while(1);
}
}
void RW1063_show_cursor() {
RW1063_send_command(0x0E);
}
void RW1063_hide_cursor() {
RW1063_send_command(0x0C);
}
void RW1063_blink_cursor() {
RW1063_send_command(0x0F);
}
void RW1063_no_blink_cursor() {
RW1063_send_command(0x0C);
}
I am also attaching images to illustrate the frames and errors encountered.
Error during debugging, HAL return
General frame
Frame focused on the clock
More detailed clock frame
I²C configuration
I²C configuration
Thank you in advance for your help!
