Menu

#3573 Need to declare a 32-bit variable in the first file

open
nobody
None
other
5
2023-05-10
2023-04-09
Rtek1000
No

Hi, I noticed unexpected behavior when trying to adapt an STM8 code compiled with Makefile, (I'm using Eclipse to run compile.sh, which then runs Makefile.)

The display blinks incorrectly if you don't declare any 32-bit variable, any name (works for: long/double/float; do not works for: char, int).

Tester board is W1209, with STM8S003F3P6.

I tested several filenames, and they always have to be with a declared 32-bit variable (first in alphabetical order).

For example: If the first file is test.c but there is no 32-bit variable declared in this file, the display blinks incorrectly. But if I add a file with a name before the letter t, like bug.c and declare a 32-bit variable in it, the display works correctly.

I didn't do tests with different projects, but apparently there's an exchange of register pointers.

1 Attachments

Discussion

  • Philipp Klaus Krause

    Trying to reproduce this, I got a W1209. Looks like the chip on it is not an STM8 though. Do you know of a source for W1209 with STM8 in Europe?

     
    • Rtek1000

      Rtek1000 - 2023-04-26

      Unfortunately this is an increasingly common problem.

      It might be easier to buy an STM8S003 or STM8S103 and replace it on the W1209 board, if the board supports the STM8S.

      Some boards had their layout modified, but others just stopped using VCAP, and it can be used with STM8S.

       
    • Rtek1000

      Rtek1000 - 2023-04-26

      I bought a W1219 board, maybe it will arrive this week.

      If this board is using an STM8S, I'll let you know later.

      This board model W1219 has two displays.

      I hope to be able to adapt the W1209 code soon.

      Ref.: https://www.aliexpress.com/item/1005005223034816.html

       
    • Rtek1000

      Rtek1000 - 2023-04-29

      Hi, the W1219 board has arrived. The MCU code is STM8S003F3P6 (IC driver: 74HC164).

       
    • Rtek1000

      Rtek1000 - 2023-04-30

      I was able to adapt the similar code, with a Timer function, to test the W1219 board, if you can buy one of those.

      Code here:

      https://github.com/rtek1000/W1209-firmware-modified/tree/master/W1219/W1219-firmware-Timer/W1219-firmware-modified-timer

      The problem with the long variable persists (flashing display)

      long foo; // compiler bug
      Line 104:

      https://github.com/rtek1000/W1209-firmware-modified/blob/master/W1219/W1219-firmware-Timer/W1219-firmware-modified-timer/Core/Src/button.c

       

      Last edit: Rtek1000 2023-05-01
      • Philipp Klaus Krause

        Both the W1209 and the W1219 I got have an IC without any markings in place of the STM8. I didn't try yet if that could be just an STM8 with sanded-off markings. But I consider it far more likely to be an IC that comes without markings on the top (e.g. Padauk that have their markings on the bottom).
        I've ordered a few STM8S003F3P6 and will see if I can put them on my boards next week (unless the unmarked ICs turn out to be STM8 after all).

         
        • Rtek1000

          Rtek1000 - 2023-05-06

          To find out if it's an STM8, just use ST-Link and STVP. If recognition error occurs, it's not STM8, but if it shows as blocked, then it's STM8. (If STVP can read it, it's definitely STM8.)

          img

          https://www.st.com/en/development-tools/stvp-stm8.html

          Other features are Reset on pin 4. And Vcap on pin 8. Other MCUs may not use Reset, and also don't use Vcap.

          img

           
          • Rtek1000

            Rtek1000 - 2023-05-06

            To unlock STM8, you can use this tab:

            img

             
            • Rtek1000

              Rtek1000 - 2023-05-06

              Note: Unlocking means losing the locked firmware (just in case someone is looking into this)

               
              • Rtek1000

                Rtek1000 - 2023-05-06

                Note: In case the board already has Vcap but STVP does not recognize the MCU, you can check if the Vcap has about 2V when the MCU is powered (usually 3V3 or 5V). Other MCUs use this pin 8 as GPIO and don't have Vcap function.

                 
          • Philipp Klaus Krause

            Looks like my W1219 is far from STM8. Pin 8 goes to the programming header there. And the trace, resistor and capacitor layout looks totally different from the pictures of STM8-based boards I saw.
            My W1209 looks closer. The board layout at first sight looks like pictures of STM8-based ones I saw. The only difference is that on my board resistor R1 is missing.

             
            • Rtek1000

              Rtek1000 - 2023-05-10

              If your W1209 board layout follows the standard scheme, then R1 must be the pull-down resistor of the output relay driver transistor.

              img

              About your W1219 board, it's unfortunate that it doesn't have the STM8 layout, some sellers take advantage of the fame of the original product, which must be with STM8.

              I even found a double model now, with two sensors and two relays, still with STM8. (One more board for pirates to change the layout hehehe)

              img

               

              Last edit: Rtek1000 2023-05-10
              • Rtek1000

                Rtek1000 - 2023-05-10

                I tried to buy an XH-3001 with STM8, but it also came with a completely different MCU, it has a soic 16 casing, with code B2R3HFH logo FMD, buying these boards inside a case is always a surprise.

                img

                 

                Last edit: Rtek1000 2023-05-10

Log in to post a comment.

MongoDB Logo MongoDB