7 years, 10 months ago.

The device is acting strange. It is not executing the program line by line?

I tried several codes: It is not considering switch case, do/while or any other function. In the program below it doesn't execute one by line instead jumps to if statement at line 252. Please help.

#include "mbed.h"
#include "TextLCD.h"

DigitalOut myled(LED3);
DigitalIn butt(D3);
DigitalIn butt1(D4);
TextLCD lcd(A0, A1, A2, A3, A4, A5);

int main()
{
    int i = 0;
    butt.mode(PullDown);
    butt1.mode(PullDown);
    do {
        if (butt == 1) {
            i++;
            wait(1);
            lcd.cls();
            lcd.locate(3,0);
            lcd.printf("Ran %d",i);
            myled = 1; // LED is ON
        }
    } while(butt1 == 0);


    lcd.cls();
    lcd.locate(3,0);
    lcd.printf("out");
    myled = 0;

}

Question relating to:

Affordable and flexible platform to ease prototyping using a STM32L031K6T6 microcontroller.

2 Answers

7 years, 10 months ago.

Check the solderbridges on the L031 (table 7 in the manual). There are some solderlinks between the D4 pin and the A4 pin (SB18), there are also links between D5 and A5 (SB16). The bridge SB18 leads to shorts between butt1 and the LCD. So you will get some random characters or maybe some random keypresses on butt1 depending on the displaydata.

The SB links are there to provide compatibility with the arduino mini layout by supporting I2C on A4,A5. Just remove the links or select another digital input instead of D4.

Accepted Answer

THANK YOU. I WILL TRY IT. HOWEVER, I TRIED THIS CODE WITHOUT CONNECTING TO D5, TO REMOVE ANY RANDOM KEYPRESS. BUT I WILL TRY AND LET YOU KNOW.

posted by jayendra mishra 10 Jun 2016

YOU ARE GENIUSS..I WASTED 3 DAYS... PLEASE TEL ME WHERE I CAN STUDY MORE ABOUT THIS SOLDERBRDGES...

posted by jayendra mishra 10 Jun 2016

You can find the user manual for the board on the ST website. See here.

posted by Wim Huiskamp 19 Jun 2016
7 years, 10 months ago.

Make your program simpler by removing statements and/or adding printf statements to see how it flows. We can't really help you with something like that which depends on alot of pin states.

I cant understand the reason that why is this code not working on this device when it was working fine on the stm l152RE. This device is not even expecting any function, I will put a new command which also dont work properly. The function ends as soon the value of i reaches more than 4. and if I press start before 4 the screen does not refresh correctly and all the numbers are scrambled.

posted by jayendra mishra 09 Jun 2016

Does the function end or does the complete program crash? As in, does it go to the .cls() command after it counted till 4?

Are you sure your wiring is correct?

posted by Erik - 09 Jun 2016

YES WIRING IS CORRECT. THE PROGRAM DOESNT CRASH. IT JUST JUMPS OUT OF DO WHILE FUNCTION. AND IF I PRESS START BUTTON BEFORE REACHING 4 THE LCD TEXT DISTORTS INSTEAD OF CLEARING THE SCREEN. THE OUT STRING IS SHOWN IN SECOND LINE.

posted by jayendra mishra 10 Jun 2016