2021-02-12 5:50 AM
We are porting a display-project from Imagecraft-compiler to IAR-compiler for the STM32F446-chip. This is the most vital bits of the LDC-drive (with ILI9488-chip). The pins are alive, checked by an oscilloscope (we don't have a logic analyzer) and the codes seem to be identical. Still no performance with the IAR-code. We can control a LED and serial ports with IAR so the compiler and download works. Any ideas?
the solution was:
The problem is solved and it seems to be the HAL-drive init of USART 3 to pin PC10 & PC11 that corrupts the initiation of PA2 and PA3 as general purpose outputs. PA2 and PA3 can also be routed to USART 3 but we use PORTA as a 16-bit parallel access to the LCD. By swapping order of initialization and first define USART 3 to PC10 & PC11 and then PORTA as parallel output it all works fine.
Working code on Imagecraft:
/* Writes 1 control-byte and then n data-bytes if n != 0 */
void LCDw_n_data( uint8_t cmd, const uint8_t *ptr, uint16_t n ) {
D_D_NC.Clear();
porta.Write( cmd );
D_WR.Clear();
D_WR.Set();
D_D_NC.Set();
while( n ) {
porta.Write( *ptr++ );
D_WR.Clear();
D_WR.Set();
n--;
}
}
/*-------------------------------------------------------------------------*/
uint16_t Background_col, Active_col;
const uint8_t str0A0A[2]={ 0x0A, 0x0A },
str4507[2] = { 0x45, 0x07},
str004280[3] = { 0x00, 0x42, 0x80 },
str00023B[3] = { 0x00, 0x02, 0x3B },
str36A5D3[3] = { 0x36, 0xA5, 0xD3 },
str36A553[3] = { 0x36, 0xA5, 0x53 },
Gamma[12] = {0x00,0x35,0x33,0x00,0x00,0x00,0x00,0x35,0x33,0x00,0x00,0x00};
void init_display( void ) {
// Hardware reset
D_RES.Clear();
waitXms( 1 );
D_RES.Set();
waitXms( 5 );
buf[0] = 0x80;
LCDw_n_data( 0xB0, buf, 1 );// Interface Mode Control
LCDw_n_data( 0xC0, str0A0A, 2 );// Power Control 1
LCDw_n_data( 0xC1, str4507, 2 );// Power Control 2
buf[0] = 0x33;
LCDw_n_data( 0xC2, buf, 1 );// Power Control 3
LCDw_n_data( 0xC5, str004280, 3 );// Power Control 4
LCDw_n_data( 0xB1, (uint8_t *)0, 0 );// Frame Rate Control
buf[0] = 0x02;
LCDw_n_data( 0xB4, buf, 1 );// Display Inversion Control
LCDw_n_data( 0xB6, str00023B, 3 );// Display Function Control
buf[0] = 0x07;
LCDw_n_data( 0xB7, buf, 1 );// Entry Mode Set
buf[0] = 0x4B; //0x8B original orientation 0x4B 180 degrees rotation
LCDw_n_data( 0x36, buf, 1 );// Memory Access Control
LCDw_n_data( 0xF0, str36A5D3, 3 );//
buf[0] = 0x80;
LCDw_n_data( 0xE5, buf, 1 );//
buf[0] = 0x01;
LCDw_n_data( 0xE5, buf, 1 );//
buf[0] = 0x00;
LCDw_n_data( 0xB3, buf, 1 );// Frame Rate Control
//buf[0] = 0x00;
LCDw_n_data( 0xE5, buf, 1 );//
LCDw_n_data( 0xF0, str36A553, 3 );//
LCDw_n_data( 0xE0, Gamma, 12 );//
buf[0] = 0x55;
LCDw_n_data( 0x3A, buf, 1 );// Interface Pixel Format
LCDw_n_data( 0x11, (uint8_t *)0, 0 ); // Sleep OUT
waitXms( 250 );
LCDw_n_data( 0x29, (uint8_t *)0, 0 ); // Display ON
Background_col = BLACK;
Active_col = WHITE;
bg_level( 3 ); // Full illumination of LCD
}
/***************************************************/And this is the non-workig code for the IAR-compiler:
#define D_RD_lo HAL_GPIO_WritePin(GPIOC,GPIO_PIN_4,GPIO_PIN_RESET)
#define D_RD_hi HAL_GPIO_WritePin(GPIOC,GPIO_PIN_4,GPIO_PIN_SET)
#define D_WR_lo HAL_GPIO_WritePin(GPIOC,GPIO_PIN_5,GPIO_PIN_RESET)
#define D_WR_hi HAL_GPIO_WritePin(GPIOC,GPIO_PIN_5,GPIO_PIN_SET)
#define D_D_NC_lo HAL_GPIO_WritePin(GPIOC,GPIO_PIN_12,GPIO_PIN_RESET)
#define D_D_NC_hi HAL_GPIO_WritePin(GPIOC,GPIO_PIN_12,GPIO_PIN_SET)
#define D_RES_lo HAL_GPIO_WritePin(GPIOC,GPIO_PIN_13,GPIO_PIN_RESET)
#define D_RES_hi HAL_GPIO_WritePin(GPIOC,GPIO_PIN_13,GPIO_PIN_SET)
/*-------------------------------------------------------------------------*/
/* Writes 1 control-byte and then n data-bytes if n != 0 */
void LCDw_n_data( uint8_t cmd, const uint8_t *ptr, uint16_t n ) {
D_D_NC_lo;
GPIOA->ODR = cmd;
D_WR_lo;
D_WR_hi;
D_D_NC_hi;
while( n ) {
GPIOA->ODR = *ptr++;
D_WR_lo;
D_WR_hi;
n--;
}
}
/*-------------------------------------------------------------------------*/
uint16_t Background_col, Active_col;
const uint8_t str1717[2]={ 0x17, 0x17 };
const uint8_t str003A80[3] = { 0x00, 0x3A, 0x80 };
const uint8_t strA9512C82[4] = { 0xA9, 0x51, 0x2C, 0x82 };
const uint8_t Gamma1[15] = {0x01,0x13,0x1E,0x00,0x0D,0x03,0x3D,
0x55,0x4F,0x06,0x10,0x0B,0x2C,0x32,0x0F};
const uint8_t Gamma2[15] = {0x08,0x10,0x15,0x03,0x0E,0x03,0x32,
0x34,0x44,0x07,0x10,0x0E,0x23,0x2E,0x0F};
const uint8_t str00223B[3] = { 0x00, 0x22, 0x3B };
const uint8_t str0000013F[4] = { 0x00, 0x00, 0x01, 0x3F };
const uint8_t str000001DF[4] = { 0x00, 0x00, 0x01, 0xDF };
void init_display( void ) {
// Hardware reset
D_RES_hi;
waitXms( 1 );
D_RES_lo;
waitXms( 10 );
D_RES_hi;
waitXms( 120 );
LCDw_n_data( 0xC0, str1717, 2 );// Power Control 1
buf[0] = 0x44;
LCDw_n_data( 0xC1, buf, 1 );// Power Control 2
LCDw_n_data( 0xC5, str003A80, 3 );// Power Control 4
buf[0] = 0x48;
LCDw_n_data( 0x36, buf, 1 );
buf[0] = 0x55;
LCDw_n_data( 0x3A, buf, 1 ); //Interface Mode Control
buf[0] = 0xA0;
LCDw_n_data( 0xB1, buf, 1 );// Frame Rate Control
buf[0] = 0x02;
LCDw_n_data( 0xB4, buf, 1 );// Display Inversion Control
buf[0] = 0x00;
LCDw_n_data( 0xE9, buf, 1 );//
LCDw_n_data( 0xF7, strA9512C82, 4 );
LCDw_n_data( 0xE0, Gamma1, 15 );//
LCDw_n_data( 0xE1, Gamma2, 15 );//
LCDw_n_data( 0xB6, str00223B, 3 );// Set rgb interface mode
LCDw_n_data( 0x2A, str0000013F, 4 );// Frame rate control
LCDw_n_data( 0x2B, str000001DF, 4 );// Display Function Control
LCDw_n_data( 0x21, (uint8_t *)0, 0 ); //
//LCDw_n_data( 0x21, (uint8_t *)0, 0 ); //
buf[0] = 0x0B; // Memory access Control Flip horizontal and vertical (0x0B, 0x4B, 0x8B, 0xCB)
LCDw_n_data( 0x36, buf, 1 );
LCDw_n_data( 0x11, (uint8_t *)0, 0 ); // Sleep OUT
waitXms( 120 );
LCDw_n_data( 0x29, (uint8_t *)0, 0 ); // Display ON
LCDw_n_data( 0x2C, (uint8_t *)0, 0 ); //
Background_col = BLACK;
Active_col = WHITE;
bg_level( 3 ); // Full illumination of LCD
}
/*-------------------------------------------------------------------------*/
// The A-port connected to the display's 16-bit parallell-port
// PC4 → nRD, PC5 → nWR, PC12 → D/nC, PC13 → nRESET
/* Configure port A in/out */
__HAL_RCC_GPIOA_CLK_ENABLE();
GPIO_InitStruct.Pin = GPIO_PIN_All; // All pins are outputs
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
// GPIO_SPEED_LOW, GPIO_SPEED_MEDIUM, GPIO_SPEED_HIGH, GPIO_SPEED_FAST
GPIO_InitStruct.Speed = GPIO_SPEED_FAST;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
// Note parallell write: GPIOA->ODR = ui;
// and parallell read: ui = GPIOA->IDR;
/* Configure port C in/out */
__HAL_RCC_GPIOC_CLK_ENABLE();
// Define outputs
GPIO_InitStruct.Pin = 0xF7B0;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FAST;
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
// Write '1' to all normally high
HAL_GPIO_WritePin(GPIOC,0x3430,GPIO_PIN_SET);
/***************************************************/
2021-02-12 6:50 AM
Hello,
"codes seem to be identical".
The bytes you are sending to the screen are not the same.
Reset sequence is longer on the non working code.
We’re moving the ST Community to a new platform to give you a better and more reliable community experience.