[9XR-PRO] Missing delay in LCD initialization. Will it fix #2852?

I need confirmation from a 9XR-PRO user. I had the bug one time
yesterday but I cannot reproduce ...
This commit is contained in:
Bertrand Songis
2015-10-19 19:35:37 +02:00
parent 9463f49ba1
commit aa88651e0a
+27 -30
View File
@@ -159,18 +159,12 @@ void lcdInit()
pioptr->PIO_OWER = 0x000000FFL; // Allow write to ls 8 bits in ODSR pioptr->PIO_OWER = 0x000000FFL; // Allow write to ls 8 bits in ODSR
#endif #endif
TC0->TC_CHANNEL[0].TC_CCR = 5; // Enable clock and trigger it (may only need trigger)
pioptr->PIO_CODR = LCD_RES; // Reset LCD pioptr->PIO_CODR = LCD_RES; // Reset LCD
while ( TC0->TC_CHANNEL[0].TC_CV < 500 ) ; // > 10us, Value depends on MCK/2 (used 18MHz)
TC0->TC_CHANNEL[0].TC_CCR = 5; // Enable clock and trigger it (may only need trigger) TC0->TC_CHANNEL[0].TC_CCR = 5; // Enable clock and trigger it (may only need trigger)
while ( TC0->TC_CHANNEL[0].TC_CV < 200 ) // > 10us, Value depends on MCK/2 (used 18MHz)
{
// Wait
}
pioptr->PIO_SODR = LCD_RES; // Remove LCD reset pioptr->PIO_SODR = LCD_RES; // Remove LCD reset
TC0->TC_CHANNEL[0].TC_CCR = 5 ; // Enable clock and trigger it (may only need trigger) while ( TC0->TC_CHANNEL[0].TC_CV < 27000 ) ; // 1500us, Value depends on MCK/2 (used 18MHz)
while ( TC0->TC_CHANNEL[0].TC_CV < 27000 ) // 1500us, Value depends on MCK/2 (used 18MHz)
{
// Wait
}
lcdSendCtl(0xe2); //Initialize the internal functions lcdSendCtl(0xe2); //Initialize the internal functions
lcdSendCtl(0xae); //DON = 0: display OFF lcdSendCtl(0xae); //DON = 0: display OFF
lcdSendCtl(0xa1); //ADC = 1: reverse direction(SEG132->SEG1) lcdSendCtl(0xa1); //ADC = 1: reverse direction(SEG132->SEG1)
@@ -182,8 +176,21 @@ void lcdInit()
lcdSendCtl(0x25); //Select int resistance ratio R2 R1 R0 =5 lcdSendCtl(0x25); //Select int resistance ratio R2 R1 R0 =5
lcdSendCtl(0x81); //Set reference voltage Mode lcdSendCtl(0x81); //Set reference voltage Mode
lcdSendCtl(0x22); // 24 SV5 SV4 SV3 SV2 SV1 SV0 = 0x18 lcdSendCtl(0x22); // 24 SV5 SV4 SV3 SV2 SV1 SV0 = 0x18
#if defined(REVX)
// 200mS delay (only if not wdt reset)
if ( ( ( ResetReason & RSTC_SR_RSTTYP ) != (2 << 8) ) && !unexpectedShutdown ) {
for (uint32_t j = 0; j < 100; j += 1 ) {
TC0->TC_CHANNEL[0].TC_CCR = 5; // Enable clock and trigger it (may only need trigger)
while ( TC0->TC_CHANNEL[0].TC_CV < 36000 ) {
// Value depends on MCK/2 (used 18MHz) give 2mS delay
wdt_reset(); // Wait
}
}
}
#endif
lcdSendCtl(0xAF); // DON = 1: display ON lcdSendCtl(0xAF); // DON = 1: display ON
// g_eeGeneral.contrast = 0x22;
#if defined(REVA) #if defined(REVA)
pioptr->PIO_ODR = 0x0000003CL; // Set bits 2, 3, 4, 5 input pioptr->PIO_ODR = 0x0000003CL; // Set bits 2, 3, 4, 5 input
@@ -217,14 +224,14 @@ void lcdSetRefVolt(uint8_t val)
lcdSendCtl(val); lcdSendCtl(val);
#if defined(REVA) #if defined(REVA)
pioptr->PIO_ODR = 0x0000003CL ; // Set bits 2, 3, 4, 5 input pioptr->PIO_ODR = 0x000000FEL; // Set bits 2, 3, 4, 5 input
pioptr->PIO_PUER = 0x0000003CL ; // Set bits 2, 3, 4, 5 with pullups pioptr->PIO_PUER = 0x000000FEL; // Set bits 2, 3, 4, 5 with pullups
#else #else
pioptr->PIO_ODR = 0x0000003AL ; // Set bits 1, 3, 4, 5 input pioptr->PIO_ODR = 0x000000FEL; // Set bits 1, 3, 4, 5 input
pioptr->PIO_PUER = 0x0000003AL ; // Set bits 1, 3, 4, 5 with pullups pioptr->PIO_PUER = 0x000000FEL; // Set bits 1, 3, 4, 5 with pullups
#endif #endif
pioptr->PIO_ODSR = lcdInputs; // Drive D0 low pioptr->PIO_ODSR = 0; // Drive D0 low
lcdLock = 0; lcdLock = 0;
} }
@@ -278,16 +285,6 @@ void lcdRefresh()
x = *p; x = *p;
#endif #endif
for (z = 0; z < LCD_W; z += 1) { for (z = 0; z < LCD_W; z += 1) {
// The following 7 lines replaces by a lookup table
// x = __RBIT( *p++ ) ;
// x >>= 23 ;
// if ( x & 0x00000100 )
// {
// x |= 1 ;
// }
// pioptr->PIO_ODSR = x ;
pioptr->PIO_ODSR = x; pioptr->PIO_ODSR = x;
pioptr->PIO_SODR = ebit; // Start E pulse pioptr->PIO_SODR = ebit; // Start E pulse
// Need a delay here (250nS) // Need a delay here (250nS)
@@ -311,13 +308,13 @@ void lcdRefresh()
pioptr->PIO_ODSR = 0xFF; // Drive lines high pioptr->PIO_ODSR = 0xFF; // Drive lines high
#if defined(REVA) #if defined(REVA)
pioptr->PIO_PUER = 0x0000003CL ; // Set bits 2, 3, 4, 5 with pullups pioptr->PIO_PUER = 0x000000FEL; // Set bits 2, 3, 4, 5 with pullups
pioptr->PIO_ODR = 0x0000003CL ; // Set bits 2, 3, 4, 5 input pioptr->PIO_ODR = 0x000000FEL; // Set bits 2, 3, 4, 5 input
#else #else
pioptr->PIO_PUER = 0x0000003AL ; // Set bits 1, 3, 4, 5 with pullups pioptr->PIO_PUER = 0x000000FEL; // Set bits 1, 3, 4, 5 with pullups
pioptr->PIO_ODR = 0x0000003AL ; // Set bits 1, 3, 4, 5 input pioptr->PIO_ODR = 0x000000FEL; // Set bits 1, 3, 4, 5 input
#endif #endif
pioptr->PIO_ODSR = lcdInputs; // Drive D0 low pioptr->PIO_ODSR = 0xFE; // Drive D0 low
lcdLock = 0; lcdLock = 0;
} }