STM32G030F6P6TR compilation error.

Post here all questions related to STM32 core if you can't find a relevant section!
Post Reply
damlevikram
Posts: 2
Joined: Mon Feb 05, 2024 6:54 am

STM32G030F6P6TR compilation error.

Post by damlevikram »

I am new to STM microcontroller and am trying to program STM32G030F6P6TR using Arduino IDE.
I am using the latest version of IDE as well as latest version of STM32 libraries.
Here is the code I am trying to flash

Code: Select all

#define SCR_Pin PA7
#define RELAY_PIN PC15
#define LED_PIN PA6
#define ZCD_PIN PA0

#define DIM_MAX 10
#define DIM_MIN 90

#define AC_CTRL_OFF digitalWrite(SCR_Pin, LOW)
#define AC_CTRL_ON digitalWrite(SCR_Pin, HIGH)

#define RELAY_OFF digitalWrite(RELAY_PIN, LOW)
#define RELAY_ON digitalWrite(RELAY_PIN, HIGH)

#define LED_OFF digitalWrite(LED_PIN, HIGH)
#define LED_ON digitalWrite(LED_PIN, LOW)

unsigned char dim = 0;

HardwareSerial mySerial(PB7, PB6);
int led_flag = 0;

void setup()
{
    pinMode(LED_PIN, OUTPUT);
    pinMode(RELAY_PIN, OUTPUT);
    pinMode(SCR_Pin, OUTPUT);
    pinMode(ZCD_PIN, INPUT);
    LED_OFF;
    RELAY_OFF;
    AC_CTRL_OFF;

    mySerial.begin(115200);
    delay(1000);
    mySerial.println("Start");

    attachInterrupt(ZCD_PIN, zero_cross_int, RISING); // CHANGE FALLING RISING
}

void loop()
{
    if (led_flag % 2 == 0)
        LED_ON;
    else
        LED_OFF;

    led_flag++;

    char c;
    String str = "";
    while (mySerial.available() > 0)
    {
        c = mySerial.read();
        if (c == '\n')
        {
            mySerial.println("Get line:");
            mySerial.println(str);
            at_explain(str);
        }
        else
            str = str + c;
    }

    delay(1000);
}

// AT D50
void at_explain(String command)
{
    if (command.startsWith("AT"))
    {
        int var_1 = 0;

        sscanf(command.c_str(), "AT D%d", &var_1);
        mySerial.println(var_1);

        set_power(var_1);
    }
}

void set_power(int level)
{
    dim = map(level, 0, 100, DIM_MIN, DIM_MAX);
    if (level == 0)
    {
        RELAY_OFF;
    }
    else
        RELAY_ON;
}

void zero_cross_int() // function to be fired at the zero crossing to dim the light
{

    if (dim <= DIM_MAX)
        return;
    // if (dim >= DIM_MIN)
    //     return;

    AC_CTRL_OFF;

    int dimtime = (100 * dim);
    delayMicroseconds(dimtime); // Off cycle
    AC_CTRL_ON;                 // triac firing
    // delayMicroseconds(500);     // triac On propagation delay
    // triac Off
}
When I try to compile this code by selecting Generic STM32G0 series from boards manager I get following error.

Code: Select all

exit status 1

Compilation error: 'PC15' was not declared in this scope; did you mean 'PC_5'?
The same code when I compile using STM32G4 series I can finish with successful compilation.

When I change the Pin names in code from
PA7 to PA_7
PC15 to PC_15 and on...
the code gets compiled with STM32G0 series. I am attaching screenshots of what is happening.
Your help in this regard is highly appreciated
by fpiSTM » Mon Feb 05, 2024 10:24 am
I've built your code for STM32G030F6P and have no error.
I guess you didn't select the correct board part number in the menu and you build for AGAFIA_SG0 which does not have PC15
Go to full post
User avatar
fpiSTM
Posts: 1723
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: STM32G030F6P6TR compilation error.

Post by fpiSTM »

I've built your code for STM32G030F6P and have no error.
I guess you didn't select the correct board part number in the menu and you build for AGAFIA_SG0 which does not have PC15
damlevikram
Posts: 2
Joined: Mon Feb 05, 2024 6:54 am

Re: STM32G030F6P6TR compilation error.

Post by damlevikram »

Thank you very much for pointing out my mistake.
What you told was correct. After selection of correct board there is no error now.
Thanks
Post Reply

Return to “General discussion”