First test on using mbed library with naked LPC1114 chip on breadboard. Blink LED pin 28, append UART test, procedure putc(), puts(), PWM beep 1kHz on pin 1.
Fork of lpc1114test by
main.cpp@4:0ae9bda1e421, 2013-11-09 (annotated)
- Committer:
- psimik
- Date:
- Sat Nov 09 16:00:56 2013 +0000
- Revision:
- 4:0ae9bda1e421
- Parent:
- 3:23f3f69678be
- Child:
- 5:051be37cfef7
PWM out moved to pin 18.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sdizdarevic | 0:15ea674d67d9 | 1 | #include "mbed.h" |
psimik | 1:8aecb799ae5e | 2 | // naked LPC1114 on breadboard |
psimik | 1:8aecb799ae5e | 3 | DigitalOut myled(dp28); // LED connect to P0_7 (pin 28) |
psimik | 3:23f3f69678be | 4 | Serial uart(dp16, dp15); // UART connect to P1_7: TX (pin 16), P1_6: RX (pin 15) |
psimik | 4:0ae9bda1e421 | 5 | PwmOut pwm(dp18); // PWM connect to P1_9: CT16B1_MAT0 (pin18) |
sdizdarevic | 0:15ea674d67d9 | 6 | |
sdizdarevic | 0:15ea674d67d9 | 7 | int main() { |
psimik | 3:23f3f69678be | 8 | char c = '0'; |
psimik | 3:23f3f69678be | 9 | pwm.period(0.001); // PWM period 1ms (1kHz) |
psimik | 1:8aecb799ae5e | 10 | uart.baud(115200); // Baud rate |
psimik | 1:8aecb799ae5e | 11 | uart.puts("Start.\n\r"); |
psimik | 1:8aecb799ae5e | 12 | while(1) { // repeat (period 1sec) |
psimik | 1:8aecb799ae5e | 13 | myled = 0; // LED on |
psimik | 3:23f3f69678be | 14 | pwm = 0.5; // PWM duty cycle 50% |
psimik | 1:8aecb799ae5e | 15 | wait(0.5); |
psimik | 2:6b5d2029ec07 | 16 | uart.putc(c++); if (c > '9') c = '0'; // Put Character & rotate 0,1,2,... 9 |
psimik | 1:8aecb799ae5e | 17 | myled = 1; // LED off |
psimik | 3:23f3f69678be | 18 | pwm = 0; // PWM stop |
psimik | 1:8aecb799ae5e | 19 | wait(0.5); |
psimik | 1:8aecb799ae5e | 20 | uart.puts(" Hello world.\n\r"); // Put String "Hello..." |
sdizdarevic | 0:15ea674d67d9 | 21 | } |
sdizdarevic | 0:15ea674d67d9 | 22 | } |