Thanks to Zoltan Hudak publish the way to use STM32F103c8t6 on mbed. Now, this example can let you use it with a encoder.
Dependencies: QEI mbed-STM32F103C8T6 mbed
Fork of STM32F103C8T6_Hello by
main.cpp@11:b6d4d3f90831, 2017-05-23 (annotated)
- Committer:
- Zeran
- Date:
- Tue May 23 16:45:28 2017 +0000
- Revision:
- 11:b6d4d3f90831
- Parent:
- 10:4b88be251088
STM32f103c8t6 encoder hello world example;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
hudakz | 5:3c3ef17a17a6 | 1 | #include "stm32f103c8t6.h" |
hudakz | 0:ab218237069e | 2 | #include "mbed.h" |
Zeran | 11:b6d4d3f90831 | 3 | #include "QEI.h" |
Zeran | 11:b6d4d3f90831 | 4 | |
hudakz | 0:ab218237069e | 5 | int main() { |
hudakz | 10:4b88be251088 | 6 | confSysClock(); //Configure system clock (72MHz HSE clock, 48MHz USB clock) |
hudakz | 10:4b88be251088 | 7 | |
hudakz | 10:4b88be251088 | 8 | Serial pc(PA_2, PA_3); |
Zeran | 11:b6d4d3f90831 | 9 | QEI wheel (PB_9, PB_8, NC, 624); |
hudakz | 10:4b88be251088 | 10 | DigitalOut myled(LED1); |
hudakz | 10:4b88be251088 | 11 | |
hudakz | 0:ab218237069e | 12 | while(1) { |
hudakz | 5:3c3ef17a17a6 | 13 | // The on-board LED is connected, via a resistor, to +3.3V (not to GND). |
hudakz | 3:c6a589f444b9 | 14 | // So to turn the LED on or off we have to set it to 0 or 1 respectively |
hudakz | 7:accb2c83a007 | 15 | myled = 0; // turn the LED on |
hudakz | 10:4b88be251088 | 16 | wait_ms(200); // 200 millisecond |
hudakz | 7:accb2c83a007 | 17 | myled = 1; // turn the LED off |
hudakz | 10:4b88be251088 | 18 | wait_ms(1000); // 1000 millisecond |
Zeran | 11:b6d4d3f90831 | 19 | pc.printf("Pulses is: %i\n", wheel.getPulses());//pc.printf("Blink\r\n"); |
hudakz | 0:ab218237069e | 20 | } |
hudakz | 0:ab218237069e | 21 | } |