trying to get GPIOA to work
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
// 2023-06-26 recallmenot
|
||||
|
||||
#define DEMO_GPIO_blink 1
|
||||
#define DEMO_GPIO_blink_port 0
|
||||
#define DEMO_GPIO_blink 0
|
||||
#define DEMO_GPIO_blink_port 0
|
||||
#define DEMO_GPIO_out 0
|
||||
#define DEMO_GPIO_in_btn 0
|
||||
#define DEMO_GPIO_in_btn 1
|
||||
#define DEMO_ADC_bargraph 0
|
||||
#define DEMO_PWM_dayrider 0
|
||||
|
||||
|
||||
@@ -6,7 +6,18 @@ int main()
|
||||
SystemInit();
|
||||
|
||||
// Enable GPIOs
|
||||
RCC->APB2PCENR |= RCC_APB2Periph_GPIOD | RCC_APB2Periph_GPIOC;
|
||||
RCC->APB2PCENR |= RCC_APB2Periph_GPIOD | RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOA | RCC_APB2Periph_AFIO;
|
||||
|
||||
// enable GPIO on A1 and A2
|
||||
//AFIO->PCFR1 &= ~GPIO_Remap_PA1_2;
|
||||
|
||||
// GPIO A1 Push-Pull
|
||||
GPIOA->CFGLR &= ~(0xf<<(4*1));
|
||||
GPIOA->CFGLR |= (GPIO_Speed_10MHz | GPIO_CNF_OUT_PP)<<(4*1);
|
||||
|
||||
// GPIO A2 Push-Pull
|
||||
GPIOA->CFGLR &= ~(0xf<<(4*2));
|
||||
GPIOA->CFGLR |= (GPIO_Speed_10MHz | GPIO_CNF_OUT_PP)<<(4*2);
|
||||
|
||||
// GPIO D0 Push-Pull
|
||||
GPIOD->CFGLR &= ~(0xf<<(4*0));
|
||||
@@ -28,9 +39,11 @@ int main()
|
||||
{
|
||||
GPIOD->BSHR = (1<<0) | (1<<4) | (1<<6); // Turn on GPIOs
|
||||
GPIOC->BSHR = (1<<0);
|
||||
GPIOA->BSHR=(1<<1) | (1<<2);
|
||||
Delay_Ms( 250 );
|
||||
GPIOD->BSHR = (1<<16) | (1<<(16+4)) | (1<<(16+6)); // Turn off GPIOs
|
||||
GPIOC->BSHR = (1<<16);
|
||||
GPIOA->BSHR=(1<<(16+1)) | (1<<(16+2));
|
||||
Delay_Ms( 250 );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,12 +130,12 @@ int main()
|
||||
for (int i=0; i<256; i++)
|
||||
{
|
||||
t1pwm_setpw(0, i);
|
||||
Delay_Ms(5);
|
||||
Delay_Ms(2);
|
||||
}
|
||||
for (int i=254; i>0; i--)
|
||||
{
|
||||
t1pwm_setpw(0, i);
|
||||
Delay_Ms(5);
|
||||
Delay_Ms(2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user