FwLib_STC8 icon indicating copy to clipboard operation
FwLib_STC8 copied to clipboard

Have simple code GPIO input/output led ?

Open Witawat opened this issue 2 years ago • 1 comments

Hello

i try codeing gpio input/output for STC8G1K08A but i can't send output port like arduino

#include "fw_hal.h"

void GPIO_Init()
{
    GPIO_P3_SetMode(GPIO_Pin_0, GPIO_Mode_Output_PP);
}

void main()
{
    GPIO_Init();
    SYS_SetClock();
    while (1)
    {
        SYS_Delay(10);
    }
}

can add simple basic code GPIO input/output led ? image

thankyou

Witawat avatar Dec 05 '22 02:12 Witawat

It's similar while the syntax/methods are different, in you code

void main()
{
    GPIO_Init();
    SYS_SetClock(); // Not needed if you just want to drive a led, wrong trim values may break the MCU from running.
    while (1)
    {
        // You need to add some code here to set the pin to output high/low voltage level to make the led blink, e.g. P30 = SET
        SYS_Delay(10);
    }
}

I have added a simple led-blink example that run on stc8g1k08a sop8.

IOsetting avatar Dec 06 '22 18:12 IOsetting