This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Kentec LCD white screen when TIVA storing data into SD card

Other Parts Discussed in Thread: TM4C123GH6PM

Hi. I need some help. I am required to do a project using TIVA C series launchpad and its LCD booster pack (Kentec LCD display). Currently facing a problem of storing data into a SD card. Basically, I need to store data into a SD card using SSI, in this case I am using SSI3. With just TIVA launchpad itself, I was successfully stored a list of data into SD card by using the push button 1 from the TIVA launchpad board. (When I press the push button 1, the data will be storing into the SD card.) After that, I tried using the Kentec LCD display together with the TIVA launchpad to store the data into the SD card. I made a push button widget on the LCD. When I press the widget, the data will be storing into the SD card. So now, the problem is, when I press the widget, the LCD will goes white screen slowly. After a few second, the screen will be completely turned white. But, the widget can still be pressed, and the data is still storing into the SD card, just without display.

I am using CCS v6.
I included the third_party/ mmc-dk-tm4c123g port.

This is my code:
////////////////////////
#include <stdint.h>
#include <stdio.h>
#include <stdbool.h>
#include "inc/tm4c123gh6pm.h"
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "inc/hw_gpio.h"
#include "driverlib/sysctl.h"
#include "driverlib/gpio.h"
#include "grlib/grlib.h"
#include "grlib/widget.h"
#include "grlib/canvas.h"
#include "grlib/pushbutton.h"
#include "Kentec320x240x16_ssd2119_8bit.h"
#include "touch.h"
#include "driverlib/fpu.h"
#include "driverlib/pin_map.h"
#include "driverlib/rom.h"
#include <string.h>
#include "fatfs/src/ff.h"
#include "fatfs/src/diskio.h"

extern tCanvasWidget g_sBackground1;
extern tPushButtonWidget g_sPushBtn1;
tContext sContext;

#ifdef DEBUG
void__error__(char *pcFilename, uint32_t ulLine)
{
}
#endif

void writeSD(char *file, char *data);
void Press(tWidget *pWidget);

unsigned int Txt_Name,count,usBytesWrite;

static FATFS g_sFatFs; // The following are data structures used by FatFs.
static FIL g_sFileObject;

char *Name[250]={"1.txt",    "2.txt",        "3.txt",        "4.txt",        "5.txt",
                "6.txt",        "7.txt",        "8.txt",        "9.txt",        "10.txt"};
char *display[11]={"0 ","1 ","2 ","3 ","4 ","5 ","6 ","7 ","8 ","9 ","10 "};
char *Next_Line = "\r\n";

Canvas(g_sBackground1, WIDGET_ROOT, 0, &g_sPushBtn1,
       &g_sKentec320x240x16_SSD2119, 110, 100, 100, 40,
       CANVAS_STYLE_FILL, ClrBlack, 0, 0, 0, 0, 0, 0);

RectangularButton(g_sPushBtn1, &g_sBackground1, 0, 0,
                  &g_sKentec320x240x16_SSD2119, 110, 100, 100, 40,
                  (PB_STYLE_OUTLINE | PB_STYLE_TEXT_OPAQUE | PB_STYLE_TEXT |
                   PB_STYLE_FILL), ClrRed, ClrRed, ClrRed, ClrWhite,
                   g_psFontCmss22b, "Press", 0, 0, 0, 0, Press);

void Press(tWidget *pWidget)
{
    f_mount(0, &g_sFatFs);
    while(f_open(&g_sFileObject, Name[Txt_Name], FA_CREATE_NEW | FA_WRITE)==FR_EXIST && Txt_Name<=9)//if the file name exist
    {
        Txt_Name++;
    }
    if(Txt_Name>=10)    //if more than 10 files exist
    {
                  //do nothing
    }
    else
    {
        for(count=0;count<=10;count++)
        {
            writeSD(Name[Txt_Name], display[count]);    //storing data into sd
        }
    }
    Txt_Name=0;
    count=0;
}
int main(void)
{
    SysCtlClockSet(SYSCTL_SYSDIV_5 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ);

    Kentec320x240x16_SSD2119Init();
    TouchScreenInit();//Using ADC0
    TouchScreenCallbackSet(WidgetPointerMessage);
    GrContextInit(&sContext, &g_sKentec320x240x16_SSD2119);

    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI3); //for sd card
    GPIOPinConfigure(GPIO_PD0_SSI3CLK);
    GPIOPinConfigure(GPIO_PD1_SSI3FSS);
    GPIOPinConfigure(GPIO_PD2_SSI3RX);
    GPIOPinConfigure(GPIO_PD3_SSI3TX);

    WidgetAdd(WIDGET_ROOT, (tWidget *)&g_sBackground1);
    WidgetPaint((tWidget *)&g_sBackground1);
    GrContextForegroundSet(&sContext, ClrLightCyan);

    while(1)
    {
        WidgetMessageQueueProcess();
    }
}
void writeSD(char *file, char *data)
{

    if (f_open(&g_sFileObject, file, FA_CREATE_NEW | FA_WRITE)==FR_OK)
    {
        if(f_write(&g_sFileObject,data,strlen(data),&usBytesWrite)==FR_OK) // write file
        {
            if(f_write(&g_sFileObject,Next_Line,strlen(Next_Line),&usBytesWrite)==FR_OK)
            {
                f_sync(&g_sFileObject);
            }
        }
    }
    else
    {
        if (f_open(&g_sFileObject, file, FA_CREATE_NEW | FA_WRITE)==FR_EXIST) // if the file is exist
        {
            if (f_open(&g_sFileObject, file, FA_OPEN_EXISTING | FA_WRITE)==FR_OK)
            {
                if(f_lseek(&g_sFileObject, g_sFileObject.fsize)==FR_OK) // write file
                {
                    if(f_write(&g_sFileObject,data,strlen(data),&usBytesWrite)==FR_OK)
                    {
                        if(f_write(&g_sFileObject,Next_Line,strlen(Next_Line),&usBytesWrite)==FR_OK)
                        {
                            f_close(&g_sFileObject);
                        }
                    }
                }
            }
        }
    }
}
//////////////////////

Anyone know what is going on?

Thanks in advance.




  • Hello. Anyone know?

  • HI,

    It is not quite clear if the white screen is a needed feature programmed by you or is an unwanted behaviour. Also would be better to know if you debugged really this application - and observe what is wrong. Just visually watching and eventually using a serial connection is not enough.

    You claim also the use of third_party/mmc-dk-tm4c123g.c file - but did you modify it? please open and read this file - there is the SPI connection configured, you need to modify some #defines for your SPI, otherwise the default is SPI0.

    As for the button - also it is your responsibility to block its activity until the data is stored.

    Petrei

  • The LCD Booster Pack uses port D, pin 2, for one LCD data line(LCD_DATAH_PIN_5), but you're also using it for the SD card, SSI3(RX).

    That's probably your problem, you'll need to use a different port(pins) for the SD card.

  • Hi. Petrei. Thank you for your reply.

    I debugged for few months already, still unable to figure out what is wrong.

    Yes, I did modified third_party/mmc-dk-tm4c123g.c  everything to SSI3, and it is successfully stored data into SD. Only the LCD went white screen after the storing process. 

    I am not really sure how to block the activity of the LCD during the storing process. Do you mind to give me some hints?

    Thanks in advance.

  • Hi Marc. Thank you for your reply.

    I was using EB-LM4F120-L35 LCD booster pack. This is the datasheet.

    http://www.farnell.com/datasheets/1653560.pdf

    From the datasheet, PD2 has no connection.

    Am I using the correct datasheet? 

  • Hi,

    Blocking can be done with a semaphore - if set then exit from push action, otherwise do push action. The semaphore should be set in push routine and cleared after the saving is done.

    Petrei

  • Hi TIPUser, I am facing the same problem like you. I also using port D since the Kentec LCD no connection with port D.
    From the kentec LCD datasheet :
    www.kentecdisplay.com/.../EB-LM4F120-L35_UserGuide_04.pdf

    Have you solve the problem so far ? Thank you
  • Hi Petrei,

    I am dont really understand the semaphore. Can you explain more about it ?

    Thank You.

    Regards,
    Jonathan
  • Jonathan Ang Jia Chen63 said:
    am dont really understand the semaphore. Can you explain more about it ?

     When you walk take great care of pole of a semaphore, when red don't cross street, when green walk.....  Programming language use this "Metafora" as primitive like the philosopher dinning to prevent dead lock...

     It is a primitive of programming art used by multitasking to block one resource to avoid be touched by others... Monitors critical sections are the TOPIC of and needed knowledge to good programming art!!!

     THIS IS TIVA RELATED FORUM!!! Basic knowledge is a must or not???? Hey CB1 we are deadlocked and we starve too due to lack of information....

  • Yes Roberto - esteemed vendor - by allowing (even encouraging) non-MCU issues - soon may run afoul of, "K & R's" famed "C" Programming book.
    Google is surprisingly good at answering such questions - an MCU-centric forum - not so much...
    This clearly is forum vendor's job - and they've "taken a (very long) "pass.""
  • cb1_mobile said:
    This clearly is forum vendor's job - and they've "taken a (very long) "pass.""

     Just see what happen, then I evaluate "pass away from".

     This way TIVA real issue got forever overkilled by all kid asking to modify two HTML lines then scream around us.