Chprintf for 2x16 LCD

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: RoccoMarco, lbednarz, tfAteba

Post Reply
szkkteam
Posts: 4
Joined: Thu Dec 24, 2015 2:23 pm

Chprintf for 2x16 LCD

Post by szkkteam »

Hello,

I've made a 2x16 LCD driver, which have a putc function. Createda BaseSequentialStream for it, to able to use the built in chprintf function.
My code is:

Code: Select all

   /* @Pseudo: Set the DB7 */
   HWI_vidDOUTWrite(LOC_pstrLcdWorkingStr->strPinConfigStructure->u8DataBit7,
         ((u8LcdDataByte & LCD_COMPARE_DB7)) >> 7);

   /* @Pseudo: Set the DB6 */
   HWI_vidDOUTWrite(LOC_pstrLcdWorkingStr->strPinConfigStructure->u8DataBit6,
         ((u8LcdDataByte & LCD_COMPARE_DB6)) >> 6 );

   /* @Pseudo: Set the DB5 */
   HWI_vidDOUTWrite(LOC_pstrLcdWorkingStr->strPinConfigStructure->u8DataBit5,
         ((u8LcdDataByte & LCD_COMPARE_DB5)) >> 5 );

   /* @Pseudo: Set the DB4 */
   HWI_vidDOUTWrite(LOC_pstrLcdWorkingStr->strPinConfigStructure->u8DataBit4,
         ((u8LcdDataByte & LCD_COMPARE_DB4)) >> 4 );

   /* @Pseudo: Set the DB3 */
   HWI_vidDOUTWrite(LOC_pstrLcdWorkingStr->strPinConfigStructure->u8DataBit3,
         ((u8LcdDataByte & LCD_COMPARE_DB3)) >> 3);

   /* @Pseudo: Set the DB2 */
   HWI_vidDOUTWrite(LOC_pstrLcdWorkingStr->strPinConfigStructure->u8DataBit2,
         ((u8LcdDataByte & LCD_COMPARE_DB2)) >> 2 );

   /* @Pseudo: Set the DB1 */
   HWI_vidDOUTWrite(LOC_pstrLcdWorkingStr->strPinConfigStructure->u8DataBit1,
         ((u8LcdDataByte & LCD_COMPARE_DB1)) >> 1 );

   /* @Pseudo: Set the DB0 */
   HWI_vidDOUTWrite(LOC_pstrLcdWorkingStr->strPinConfigStructure->u8DataBit0,
         ((u8LcdDataByte & LCD_COMPARE_DB0)) >> 0 );

   /* @Pseudo: Generate 1 clock to EN       */
   vidLcdStrobePin(PIN_EN);



the vidLcdStrobePin is a macro which contains a EN = High, chThdSleepMicroseconds(500), then EN = Low.

When the software initializing the tasks chprintf(&LCDStreamData, "TEST") is called, and the charachters are shown on the LCD.

But when I call this function again in a periodic task, the software freeze. and the openocd show the following error:

Code: Select all

Error: ChibiOS registry integrity check failed, double linked list violation
Info : Only showing current execution because of a broken ChibiOS thread registry.


Other infos: If I decrement the chThdSleepMicroseconds values lower then 500 uS the LCD not working, but in the reference document there is a 500 nS minimum EN pulse.

Any idea why this can happen?
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Chprintf for 2x16 LCD

Post by Giovanni »

Hi,

It is a memory corruption, it is usually caused by a stack overflow but it is not the only possible cause.

Enable the debug options in chconf.h and verify if something is caught (assertions, checks, state checker, stack overflow check). In case of errors the system is stop and you can inspect the cause.

Giovanni
szkkteam
Posts: 4
Joined: Thu Dec 24, 2015 2:23 pm

Re: Chprintf for 2x16 LCD

Post by szkkteam »

Thank you very much. The size of the working area was too low for the thread. Now I increased the limit, and it's working fine. My mistake :)
Post Reply