Re: Taking a look at STM32G0 series
Posted: Fri Mar 03, 2023 7:06 pm
got my arduino clone up and running on this thing. haven't thoroughly tested it yet.
not bad for a sub-$1 chip.
not bad for a sub-$1 chip.
Everything relating to using STM32 boards with the Arduino IDE and alternatives
https://www.stm32duino.com/
all i did is to solder the chip to the board. no other components at all.I'd likely try HSI
with a calibrated LSI driving the RTC, I gained < 1s over 3 hours, or better than 100ppm.they ran about about 32.1K - 32.2Khz, vs. 32.0K spec.
if you find it helpful, this is how I deal with such problems:It'd take a little time to figure out what can be mapped at any one time on the shared and dedicated paxx pins
Code: Select all
#define U2TX2PIN() U2TX2PA2() //u2tx to pa2, pa14
//#define U2RX2PIN() U2RX2PA3() //u2rx to pa3, pa15
Code: Select all
#if defined(U2TX2PIN)
U2TX2PIN(); //activate tx pin
#endif
#if defined(U2RX2PIN)
U2RX2PIN(); //activate rx pin
#endif
Code: Select all
//u2tx/rx pins
#define U2TX2PA2() pinAFIO(PA2, AFIO1) //U2TX to PA2, AF1
#define U2RX2PA3() pinAFIO(PA3, AFIO1) //U2RX to PA3, AF1
#define U2TX2PA14() pinAFIO(PA13,AFIO1) //U2TX to PA14,AF1
#define U2RX2PA15() pinAFIO(PA15,AFIO1) //U2RX to PA15,AF1
Code: Select all
//configure pin for AFIO
void pinAFIO(PIN_TypeDef pin, AFIO_TypeDef AFIOn) {
uint32_t pos;
GPIO_TypeDef *gpio;
gpio=GPIO_PinDef[pin].gpio;
//mask=GPIO_PinDef[pin].mask;
pos = pinPos(GPIO_PinDef[pin].mask);
gpio->MODER = (gpio->MODER &~(/*0b11*/0x03<<(2* pos))) | (/*0b10*/0x02<<(2* pos));
gpio->OTYPER &=~(1<< pos);
gpio->OSPEEDR = (gpio->OSPEEDR &~(/*0b11*/0x03<<(2* pos))) | (/*0b01*/0x01<<(2* pos));
if (pos<8) gpio->AFR[0] = (gpio->AFR[0] &~(0x0f<<(4*( pos%8)))) | ((AFIOn-AFIO0)<<(4*( pos%8)));
else gpio->AFR[1] = (gpio->AFR[1] &~(0x0f<<(4*( pos%8)))) | ((AFIOn-AFIO0)<<(4*( pos%8)));
}
Code: Select all
const PIN2GPIO GPIO_PinDef[]={
#if defined(GPIOA)
{GPIOA, 1<<0}, //STM32duino Pin 0 = RP0/PB0/CHIP PIN4
{GPIOA, 1<<1}, //STM32duino Pin 1 = RP1/PB1/CHIP PIN5
{GPIOA, 1<<2}, //STM32duino Pin 2 = RP2/PB2/CHIP PIN6
{GPIOA, 1<<3}, //STM32duino Pin 3 = RP3/PB3/CHIP PIN7
{GPIOA, 1<<4}, //STM32duino Pin 4 = RP4/PB4/CHIP PIN11
{GPIOA, 1<<5}, //STM32duino Pin 5 = RP5/PB5/CHIP PIN14
{GPIOA, 1<<6}, //STM32duino Pin 6 = RP6/PB6/CHIP PIN15
{GPIOA, 1<<7}, //STM32duino Pin 7 = RP7/PB7/CHIP PIN16
{GPIOA, 1<<8}, //STM32duino Pin 8 = RP8/PB8/CHIP PIN17
{GPIOA, 1<<9}, //STM32duino Pin 9 = RP9/PB9/CHIP PIN18
{GPIOA, 1<<10}, //STM32duino Pin 10 = RP10/PB10/CHIP PIN21
{GPIOA, 1<<11}, //STM32duino Pin 11 = RP11/PB11/CHIP PIN22
{GPIOA, 1<<12}, //STM32duino Pin 12 = RP12/PB12/CHIP PIN23
{GPIOA, 1<<13}, //STM32duino Pin 13 = RP13/PB13/CHIP PIN24
{GPIOA, 1<<14}, //STM32duino Pin 14 = RP14/PB14/CHIP PIN25
{GPIOA, 1<<15}, //STM32duino Pin 15 = RP15/PB15/CHIP PIN26
#endif
...
Code: Select all
//map pin number to GPIOx
typedef struct {
GPIO_TypeDef *gpio; //gpio for a pin
uint16_t mask; //pin mask - 16-bit port
} PIN2GPIO;