motor control code by JYB
Dependencies: mbed-dev-f303 FastPWM3
Diff: hw_setup.cpp
- Revision:
- 47:f4ecf3e0576a
- Parent:
- 37:c0f352d6e8e3
--- a/hw_setup.cpp Mon Jul 30 20:33:23 2018 +0000 +++ b/hw_setup.cpp Wed May 13 09:53:27 2020 +0000 @@ -11,7 +11,11 @@ RCC->APB1ENR |= 0x00000001; // enable TIM2 clock RCC->APB2ENR |= RCC_APB2ENR_TIM1EN; // enable TIM1 clock - GPIOC->MODER |= (1 << 10); // set pin 5 to be general purpose output for LED + // GPIOC->MODER |= (1 << 10); // set pin 5 to be general purpose output for LED + GPIOB->MODER |= (1); // pB_0, output + GPIOB->MODER |= (1 << 2); // PB_1, output + + gpio->enable = new DigitalOut(ENABLE_PIN); gpio->pwm_u = new FastPWM(PIN_U); gpio->pwm_v = new FastPWM(PIN_V); @@ -54,13 +58,17 @@ ADC2->CR2 |= ADC_CR2_ADON;//0x00000001; // ADC2 ON ADC2->SQR3 = 0x0000000B; // use PC_1 as input - ADC2_IN11 ADC3->CR2 |= ADC_CR2_ADON; // ADC3 ON - ADC3->SQR3 = 0x00000000; // use PA_0, - ADC3_IN0 - GPIOC->MODER |= 0x0000000f; // Alternate function, PC_0, PC_1 are analog inputs - GPIOA->MODER |= 0x3; // PA_0 as analog input + // ADC3->SQR3 = 0x00000000; // use PA_0, - ADC3_IN0 + ADC3->SQR3 = 0x0000000D; // PC_4 a, ADC3)IN0 + // GPIOC->MODER |= 0x0000000f; // Alternate function, PC_0, PC_1 are analog inputs + GPIOC->MODER |= 0x000000cf; + + // GPIOA->MODER |= 0x3; // PA_0 as analog input ADC1->SMPR1 |= 0x1; // 15 cycles on CH_10, 0b 001 ADC2->SMPR1 |= 0x8; // 15 cycles on CH_11, 0b 0001 000 - ADC3->SMPR2 |= 0x1; // 15 cycles on CH_0, 0b 001; + // ADC3->SMPR2 |= 0x1; // 15 cycles on CH_0, 0b 001; + ADC3->SMPR1 |= 0x0200; // 15 cycles on CH_13, 0b 001 000 000 000