Skip to main content
VSrin
Associate III
October 8, 2019
Question

Can someone give me any link for bare metal programming of LCD in stm8l discovery. Any help would be greatly appreciated

  • October 8, 2019
  • 4 replies
  • 2120 views

..

    This topic has been closed for replies.

    4 replies

    Associate III
    October 9, 2019

    Standard Peripheral Library have a good example relative to LCD. Details of LCD control you can extract from corresponding source file of this library. See application note also. https://www.st.com/content/ccc/resource/technical/document/application_note/0d/99/cb/9c/dc/73/42/52/CD00257713.pdf/files/CD00257713.pdf/jcr:content/translations/en.CD00257713.pdf

    VSrin
    VSrinAuthor
    Associate III
    October 9, 2019

    I have a quick question? I use ST visual develop and I could not see my variables getting incremented if I set the variables as static.

    #include <iostm8l.h>

    #include <stdio.h>

    #include <string.h>

    #include <stdlib.h>

    #include <stdint.h>

    #include <math.h>

    #include "defs.h"

    static int click = 0;

    void delay(unsigned long dd)

    {

      unsigned long i;

      for (i=0;i<dd;i++) nop(); 

    }

    void RTC(void)

    {

    unsigned long j = 0;

    PE_ODR |= 0x80; // led indication for reset 

    if( click == 2) // reset module

    {

    click = 0;

     PC_ODR &= ~(1<<3); //pc3 in place of push button - turn it off here

     for(j = 0;j<20;j++)

     {

      delay(_250ms_); // 4.3 seconds in real

     }

    }

    if(click == 1) // on module

    {

    click++;

    PC_ODR &= ~(1<<3); //turn it off

    for(j = 0;j<8;j++)

     {

    delay(_250ms_); // wait

     }

    }

    if (click == 0) // off module

    {

    PC_ODR &= ~(1<<3); //turn it off

    click++;

     for(j = 0;j<8;j++)

     {

    delay(_250ms_); // wait

     }

      PC_ODR |= (1<<3); // turn it on

     for(j = 0;j<8;j++)

     {

    delay(_250ms_); // wait

     }

     PC_ODR &= ~(1<<3); //turn it off

     for(j = 0;j<8;j++)

     {

    delay(_250ms_); // wait

     }

    }

    RTC_ISR2=0x00; // clear interrupt flags

    }

    void SetupTimers(void)

    {

    CLK_CRTCR=0x04; // use iternal LSI/1 clock @ ~38KHz

     RTC_WPR=0xCA;

    RTC_WPR=0x53;

    RTC_CR2=0x00; // disable wakeup timer for register update

    while(!(RTC_ISR1 & 0x04));

      RTC_CR1=0x04; // set 1hz clk

    RTC_WUTRH=0x00; // change here for time change

    RTC_WUTRL=0x78; //2 min timer

    RTC_CR3=0x00; 

    RTC_CR2=0x44; // turn on timer and interrupt

    RTC_WPR=0xFF; // lock the device

    }

    main()

    {

    CLK_DIVR = 0x00; // Set the frequency to 16Mhz

    CLK_PCKENR2 = 0x07; // clock for timer1

     PC_DDR = 0x08; //direction input for push button

    PC_CR1 = 0x08; //floating input pc3

    PE_DDR = 0x80; // direction output for led

     PE_CR1 = 0x80; // fast push pull mode

    SetupTimers();

    _asm("rim\n"); // enable interrupt

    while(1)

    {

    PC_ODR |= (1<<3); // turn it on

    PE_ODR &= ~(0x80);

    }

    }

    VSrin
    VSrinAuthor
    Associate III
    October 9, 2019

    The static click remains 0 all the time

    Associate III
    October 9, 2019

    STVD MCU simulator have some limitation of functionality. As example you must stimulate interrupts requests manually. To make the program understandable, best use the definitions from the Standard Peripheral Library.