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.

TM4C123GXL Lab 10 question (How to integrate the sine wave code [Lab9] into Lab 10 so it can show up on the Kentec LCD display)Hell



Hello, currently im doing the bonus question, and i am wondering, how do i combine the lab 9 sine wave code into lab 10 so it shows up on the kentec lcd display? Thanks!!

  • Hi,
    Ignoring Lab9 and lab10 - you have an example of sine drawing on display in your Tiva/examples/boards/ek-lm4f232/sine_demo folder.
  • Hello, thanks for your reply, but isnt the lm4f232 board different from the tm4c123 ? Which means the code will be different as well
  • Hello Desmond

    Yes and No. LM4F232 is different from TM4C123 but not in the programming model but other features that should not make a difference from use perspective

    Regards
    Amit
  • I see ok. Thanks for your help :) Will read up more on it.
  • Hello, is there a more practical example? I looked through the sine demo in LM4F232 but am still equally lost on how to start on creating a sine wave
  • Hello Desmond,

    What do you mean by a more practical example!!!

    Regards
    Amit
  • I was looking thru the coding but i couldn't make sense out of it. Is there a tutorial or a breakdown? Sorry im not very good when it comes to coding for a sine wave
  • Hello Desmond,

    The code comes with a readme. I think you would first need to understand how to create a sine wave, understand the function calls being made and the operations being performed. My I suggest "age-old" pen & paper design.

    Regards
    Amit
  • Hello, this is the code i have come up with, is it possible to help me with it.


    #include <stdint.h>
    #include <stdbool.h>
    #include "inc/hw_memmap.h"
    #include "inc/hw_types.h"
    #include "driverlib/debug.h"
    #include "driverlib/sysctl.h"
    #include "grlib/grlib.h"
    #include "Kentec320x240x16_ssd2119_8bit.h"
    #include "LCD_Screen.h"
    #include "touch.h"
    #include "grlib/widget.h"

    tContext gsContext;
    tRectangle gsRect;



    uint16_t length;//ui16h
    uint16_t width;//ui16v
    uint32_t ui32ADC_ValueAvg;





    void main(void)

    {
    SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ);
    GrContextInit(&gsContext, &g_sKentec320x240x16_SSD2119);
    LCD_Screen_clear();
    LCD_Screen_putGridDots5_10_50(); //Draw grid of 5, 10, 50 pix dots; diff colors
    Kentec320x240x16_SSD2119Init();

    SysCtlDelay(SysCtlClockGet());

    //Get and plot the first pixel
    //ui32ADC_ValueAvg = ADC0_Seq1_SW_Avg4_conv();//ui32ADC_ValueAvg = 0..4095 for 0..+3.3V
    length = 0; //Initial pix position is left of screen
    width = 240 - 1 - (ui32ADC_ValueAvg/20); //Scale down ADC to fit LCD screen
    GrPixelDraw(&gsContext, length, width);//Plot the first pixel

    while(1)
    {

    // ui32ADC_ValueAvg = ADC0_Seq1_SW_Avg4_conv();//ui32ADC_ValueAvg = 0..4095 for 0..+3.3V
    width = 240 - 1 - (ui32ADC_ValueAvg/20); //Scale down ADC to fit LCD screen
    length++; //Get horiz pix position
    if(length>=320) length = 0; //Restart to left of screen
    GrPixelDraw(&gsContext, length, width);//Plot the first pixel

    WidgetMessageQueueProcess();
    }

    }
  • Hello Desmond,

    Since this is the Kentec Display booster pack, I am not sure if the interface is a SSI based or a parallel port. You may have to first check if the connection requirement for the Display booster pack and then see if the Initialization routine is handling the interface in the correct manner

    Regards
    Amit
  • Hello, i understand but now after a clearer picture, i think i need to focus more on pixel plotting. Is there any guide for me to use to understand pixel plotting on the kentec more?

  • Hello, after seeking advice, i made a new code, but if my array requires 100 values inside to form a sine wave, do i need to type all 100 values into the array?

    #include <stdint.h>
    #include <stdbool.h>
    #include <math.h>
    #include "inc/hw_memmap.h"
    #include "inc/hw_types.h"
    #include "driverlib/fpu.h"
    #include "inc/hw_types.h"
    #include "driverlib/interrupt.h"
    #include "driverlib/sysctl.h"
    #include "driverlib/gpio.h"
    #include "grlib/grlib.h"
    #include "grlib/widget.h"
    #include "grlib/canvas.h"
    #include "Kentec320x240x16_ssd2119_8bit.h"
    #include "driverlib/rom.h"
    #ifndef M_PI
    #define M_PI 3.14159265358979323846
    #endif
    int32_t i32DataCount;

    tContext gsContext;
    uint16_t aui16Data[]={
    100,101

    };

    void main(void){
    uint32_t h;
    uint32_t v;

    SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_XTAL_16MHZ | SYSCTL_OSC_MAIN);

    GrContextInit(&gsContext, &g_sKentec320x240x16_SSD2119);
    Kentec320x240x16_SSD2119Init();
    SysCtlDelay(SysCtlClockGet());
    //LCD_Screen_clear();

    GrContextForegroundSet(&gsContext, ClrAqua);
    GrContextFontSet(&gsContext, &g_sFontCmss14b);
    GrStringDraw(&gsContext, "Testing", -1, 0, 2, 0);//psContext, *pcString,i32Length,i32X, i32Y,bOpaque
    //Get and plot the first pixel
    for(h=0;h<30;h++){
    v= aui16Data[h];
    GrPixelDraw(&gsContext, h, v);
    }
    while(1){

    }
    }
  • Hello Desmond

    No. You can compute each value as in Lab 9 and display the pixel before going to the next value.

    Regards
    Amit
  • Hello, thanks for your reply. Could u explain what u mean by computing each value? Im not very clear on what it means.

  • Hello Desmond,

    As an example if you want to compute 10 values randomly, there are 2 ways of doing so

    1. Take an array and use the function rand() to populate the same
    2. Take one variable and when required use the function rand() to get a new value and use it.

    Regards
    Amit
  • Sorry but how do u call the rand() function, sorry if my question sounds dumb as i have no idea how to do it. I tried googling but the answers aren't what im looking for.

  • Hello Desmond.

    Use of rand function was an example. There would be sine functions in math.h that needs to be called.

    Regards
    Amit
  • Might there be an (easier) "extra-credit" method for you? (i.e. one that may not require "months" of back-forth to solve...)

    Extra credit (appears) worthwhile - but should not (some) attempt be made to match the goal to user understanding/capability?
  • This is becos it's part of my project and I am tasked to be able to generate some form of results on the kentec lcd display.

    Right now I am leaning towards developing codes for producing a sine wave on the lcd display. However,  I am not very certain of the functions required. As I have already asked above

  • Hello. Thanks for your replies. This is all very new to me. Hence me not knowing much. Is it too much of a trouble for u to be able to post some code examples? Thanks
  • Hi Desmond,
    There are not any other simplest examples. What can we/I do to help you is to add two special comments for you:

    a) First is about the sine_demo example. As you probably know, the sine is taken at several points, equally spaced. To display them there are two possible cases: the first one is to take N samples and store them into an array, then making use of graphic functions to send them to the display. This means we need a "for" loop to compute and store them. But after we sent them to the display, there is nothing to do, so a while(1) loop will be empty.
    For reasons not to be discussed now, we can replace the for loop with the while(1) loop itself, computing one sample at the time, placing into an array, and displaying the result. This has a secondary effect to generate a slow moving (to the left) sine wave. This is the example provided by TI. To create the moving effect, the waveform samples are moved into memory (see the memmove function call) one sample up (the second becomes the first) and creating room for a new (latest) sample.

    b) From practical point of view, what can you do: supposing you use the CCS, then just import the sine_demo example, compile/link it and stop at this stage, do not run. But examine your project structure and the settings - you will find out some files added to the project - the drivers for the display and the graphics library.
    Then start a new project, this time for your micro, and make it to contain the same files as the previous one, except for the display drivers, where you need to use the drivers for your display. Compile and link and this time run it. Take care about the settings.

    That's all.

  • okay thanks for your help. I will do as u have advised ^.^ U guys have been a great help!