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.

Dependencies:   mbed

Fork of lpc1114test by Saudin Dizdarevic

Committer:
psimik
Date:
Sat Nov 09 15:53:14 2013 +0000
Revision:
3:23f3f69678be
Parent:
2:6b5d2029ec07
Child:
4:0ae9bda1e421
Append PWM test, connect piezo-buzzer on pin1.

Who changed what in which revision?

UserRevisionLine numberNew 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 3:23f3f69678be 5 PwmOut pwm(dp1); // PWM connect to P0_8: CT16B0_MAT0 (pin1) provisional, blocking SPI! (MISO)
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 }