This program demonstrates the usage of the ADC. Program sets pin P1.31 as an ADC chanel 5 input to which we connect the potentiometer. Program then turns on an embedded LED on the LPC4088 QSB when the potentiometer's digital value exceeds the middle value.
Dependencies: mbed
Revision 0:3b7f012600ec, committed 2015-05-02
- Comitter:
- 71GA
- Date:
- Sat May 02 17:33:44 2015 +0000
- Commit message:
- This is the first commit of this program.
Changed in this revision
diff -r 000000000000 -r 3b7f012600ec LPC4088-adc.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LPC4088-adc.h Sat May 02 17:33:44 2015 +0000 @@ -0,0 +1,17 @@ +//register definitions for ADC peripheral + +#define CR (*((volatile unsigned int *) 0x40034000)) +#define GDR (*((volatile unsigned int *) 0x40034004)) +#define INTEN (*((volatile unsigned int *) 0x4003400C)) + +#define DR0 (*((volatile unsigned int *) 0x40034010)) +#define DR1 (*((volatile unsigned int *) 0x40034014)) +#define DR2 (*((volatile unsigned int *) 0x40034018)) +#define DR3 (*((volatile unsigned int *) 0x4003401C)) +#define DR4 (*((volatile unsigned int *) 0x40034020)) +#define DR5 (*((volatile unsigned int *) 0x40034024)) +#define DR6 (*((volatile unsigned int *) 0x40034028)) +#define DR7 (*((volatile unsigned int *) 0x4003402C)) + +#define STAT (*((volatile unsigned int *) 0x40034030)) +#define TRM (*((volatile unsigned int *) 0x40034034)) \ No newline at end of file
diff -r 000000000000 -r 3b7f012600ec LPC4088-gpio.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LPC4088-gpio.h Sat May 02 17:33:44 2015 +0000 @@ -0,0 +1,52 @@ +//definicija registrov za periferijo GPIO + +//GPIO +#define DIR0 (*((volatile unsigned int *) 0x20098000)) //Port0 +#define MASK0 (*((volatile unsigned int *) 0x20098010)) +#define PIN0 (*((volatile unsigned int *) 0x20098014)) +#define SET0 (*((volatile unsigned int *) 0x20098018)) +#define CLR0 (*((volatile unsigned int *) 0x2009801C)) + +#define DIR1 (*((volatile unsigned int *) 0x20098020)) //Port1 +#define MASK1 (*((volatile unsigned int *) 0x20098030)) +#define PIN1 (*((volatile unsigned int *) 0x20098034)) +#define SET1 (*((volatile unsigned int *) 0x20098038)) +#define CLR1 (*((volatile unsigned int *) 0x2009803C)) + +#define DIR2 (*((volatile unsigned int *) 0x20098040)) //Port2 +#define MASK2 (*((volatile unsigned int *) 0x20098050)) +#define PIN2 (*((volatile unsigned int *) 0x20098054)) +#define SET2 (*((volatile unsigned int *) 0x20098058)) +#define CLR2 (*((volatile unsigned int *) 0x2009805C)) + +#define DIR3 (*((volatile unsigned int *) 0x20098060)) //Port3 +#define MASK3 (*((volatile unsigned int *) 0x20098070)) +#define PIN3 (*((volatile unsigned int *) 0x20098074)) +#define SET3 (*((volatile unsigned int *) 0x20098078)) +#define CLR3 (*((volatile unsigned int *) 0x2009807C)) + +#define DIR4 (*((volatile unsigned int *) 0x20098080)) //Port4 +#define MASK4 (*((volatile unsigned int *) 0x20098090)) +#define PIN4 (*((volatile unsigned int *) 0x20098094)) +#define SET4 (*((volatile unsigned int *) 0x20098098)) +#define CLR4 (*((volatile unsigned int *) 0x2009809C)) + +#define DIR5 (*((volatile unsigned int *) 0x200980A0)) //Port5 +#define MASK5 (*((volatile unsigned int *) 0x200980B0)) +#define PIN5 (*((volatile unsigned int *) 0x200980B4)) +#define SET5 (*((volatile unsigned int *) 0x200980B8)) +#define CLR5 (*((volatile unsigned int *) 0x200980BC)) + + +//GPIO interrupts +#define int_STATUS (*((volatile unsigned int *) 0x40028080)) +#define int_STATR0 (*((volatile unsigned int *) 0x40028084)) +#define int_STATF0 (*((volatile unsigned int *) 0x40028088)) +#define int_CLR0 (*((volatile unsigned int *) 0x4002808C)) +#define int_ENR0 (*((volatile unsigned int *) 0x40028090)) +#define int_ENF0 (*((volatile unsigned int *) 0x40028094)) +#define int_STATR2 (*((volatile unsigned int *) 0x400280A4)) +#define int_STATF2 (*((volatile unsigned int *) 0x400280A8)) +#define int_CLR2 (*((volatile unsigned int *) 0x400280AC)) +#define int_ENR2 (*((volatile unsigned int *) 0x400280B0)) +#define int_ENF2 (*((volatile unsigned int *) 0x400280B4))
diff -r 000000000000 -r 3b7f012600ec LPC4088-ioconfig.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LPC4088-ioconfig.h Sat May 02 17:33:44 2015 +0000 @@ -0,0 +1,178 @@ +//Definicije registrov za periferijo IOCONFIG + +//Port 0 +#define IOCON_P0_0 (*((volatile unsigned int *) 0x4002C000)) //D (IOCON type) +#define IOCON_P0_1 (*((volatile unsigned int *) 0x4002C004)) //D +#define IOCON_P0_2 (*((volatile unsigned int *) 0x4002C008)) //D +#define IOCON_P0_3 (*((volatile unsigned int *) 0x4002C00C)) //D +#define IOCON_P0_4 (*((volatile unsigned int *) 0x4002C010)) //D +#define IOCON_P0_5 (*((volatile unsigned int *) 0x4002C014)) //D +#define IOCON_P0_6 (*((volatile unsigned int *) 0x4002C018)) //D +#define IOCON_P0_7 (*((volatile unsigned int *) 0x4002C01C)) //W +#define IOCON_P0_8 (*((volatile unsigned int *) 0x4002C020)) //W +#define IOCON_P0_9 (*((volatile unsigned int *) 0x4002C024)) //W +#define IOCON_P0_10 (*((volatile unsigned int *) 0x4002C028)) //D +#define IOCON_P0_11 (*((volatile unsigned int *) 0x4002C02C)) //D +#define IOCON_P0_12 (*((volatile unsigned int *) 0x4002C030)) //A +#define IOCON_P0_13 (*((volatile unsigned int *) 0x4002C034)) //A +#define IOCON_P0_14 (*((volatile unsigned int *) 0x4002C038)) //D +#define IOCON_P0_15 (*((volatile unsigned int *) 0x4002C03C)) //D +#define IOCON_P0_16 (*((volatile unsigned int *) 0x4002C040)) //D +#define IOCON_P0_17 (*((volatile unsigned int *) 0x4002C044)) //D +#define IOCON_P0_18 (*((volatile unsigned int *) 0x4002C048)) //D +#define IOCON_P0_19 (*((volatile unsigned int *) 0x4002C04C)) //D +#define IOCON_P0_20 (*((volatile unsigned int *) 0x4002C050)) //D +#define IOCON_P0_21 (*((volatile unsigned int *) 0x4002C054)) //D +#define IOCON_P0_22 (*((volatile unsigned int *) 0x4002C058)) //D +#define IOCON_P0_23 (*((volatile unsigned int *) 0x4002C05C)) //A +#define IOCON_P0_24 (*((volatile unsigned int *) 0x4002C060)) //A +#define IOCON_P0_25 (*((volatile unsigned int *) 0x4002C064)) //A +#define IOCON_P0_26 (*((volatile unsigned int *) 0x4002C068)) //A +#define IOCON_P0_27 (*((volatile unsigned int *) 0x4002C06C)) //I +#define IOCON_P0_28 (*((volatile unsigned int *) 0x4002C070)) //I +#define IOCON_P0_29 (*((volatile unsigned int *) 0x4002C074)) //U +#define IOCON_P0_30 (*((volatile unsigned int *) 0x4002C078)) //U +#define IOCON_P0_31 (*((volatile unsigned int *) 0x4002C07C)) //U + +//Port 1 +#define IOCON_P1_0 (*((volatile unsigned int *) 0x4002C080)) //D (IOCON type) +#define IOCON_P1_1 (*((volatile unsigned int *) 0x4002C084)) //D +#define IOCON_P1_2 (*((volatile unsigned int *) 0x4002C088)) //D +#define IOCON_P1_3 (*((volatile unsigned int *) 0x4002C08C)) //D +#define IOCON_P1_4 (*((volatile unsigned int *) 0x4002C090)) //D +#define IOCON_P1_5 (*((volatile unsigned int *) 0x4002C094)) //W +#define IOCON_P1_6 (*((volatile unsigned int *) 0x4002C098)) //W +#define IOCON_P1_7 (*((volatile unsigned int *) 0x4002C09C)) //W +#define IOCON_P1_8 (*((volatile unsigned int *) 0x4002C0A0)) //D +#define IOCON_P1_9 (*((volatile unsigned int *) 0x4002C0A4)) //D +#define IOCON_P1_10 (*((volatile unsigned int *) 0x4002C0A8)) //D +#define IOCON_P1_11 (*((volatile unsigned int *) 0x4002C0AC)) //D +#define IOCON_P1_12 (*((volatile unsigned int *) 0x4002C0B0)) //D +#define IOCON_P1_13 (*((volatile unsigned int *) 0x4002C0B4)) //D +#define IOCON_P1_14 (*((volatile unsigned int *) 0x4002C0B8)) //W +#define IOCON_P1_15 (*((volatile unsigned int *) 0x4002C0BC)) //D +#define IOCON_P1_16 (*((volatile unsigned int *) 0x4002C0C0)) //W +#define IOCON_P1_17 (*((volatile unsigned int *) 0x4002C0C4)) //W +#define IOCON_P1_18 (*((volatile unsigned int *) 0x4002C0C8)) //D +#define IOCON_P1_19 (*((volatile unsigned int *) 0x4002C0CC)) //D +#define IOCON_P1_20 (*((volatile unsigned int *) 0x4002C0D0)) //D +#define IOCON_P1_21 (*((volatile unsigned int *) 0x4002C0D4)) //D +#define IOCON_P1_22 (*((volatile unsigned int *) 0x4002C0D8)) //D +#define IOCON_P1_23 (*((volatile unsigned int *) 0x4002C0DC)) //D +#define IOCON_P1_24 (*((volatile unsigned int *) 0x4002C0E0)) //D +#define IOCON_P1_25 (*((volatile unsigned int *) 0x4002C0E4)) //D +#define IOCON_P1_26 (*((volatile unsigned int *) 0x4002C0E8)) //D +#define IOCON_P1_27 (*((volatile unsigned int *) 0x4002C0EC)) //D +#define IOCON_P1_28 (*((volatile unsigned int *) 0x4002C0F0)) //D +#define IOCON_P1_29 (*((volatile unsigned int *) 0x4002C0F4)) //D +#define IOCON_P1_30 (*((volatile unsigned int *) 0x4002C0F8)) //A +#define IOCON_P1_31 (*((volatile unsigned int *) 0x4002C0FC)) //A + +//Port 2 +#define IOCON_P2_0 (*((volatile unsigned int *) 0x4002C100)) //D (IOCON type) +#define IOCON_P2_1 (*((volatile unsigned int *) 0x4002C104)) //D +#define IOCON_P2_2 (*((volatile unsigned int *) 0x4002C108)) //D +#define IOCON_P2_3 (*((volatile unsigned int *) 0x4002C10C)) //D +#define IOCON_P2_4 (*((volatile unsigned int *) 0x4002C110)) //D +#define IOCON_P2_5 (*((volatile unsigned int *) 0x4002C114)) //D +#define IOCON_P2_6 (*((volatile unsigned int *) 0x4002C118)) //D +#define IOCON_P2_7 (*((volatile unsigned int *) 0x4002C11C)) //D +#define IOCON_P2_8 (*((volatile unsigned int *) 0x4002C120)) //D +#define IOCON_P2_9 (*((volatile unsigned int *) 0x4002C124)) //D +#define IOCON_P2_10 (*((volatile unsigned int *) 0x4002C128)) //D +#define IOCON_P2_11 (*((volatile unsigned int *) 0x4002C12C)) //D +#define IOCON_P2_12 (*((volatile unsigned int *) 0x4002C130)) //D +#define IOCON_P2_13 (*((volatile unsigned int *) 0x4002C134)) //D +#define IOCON_P2_14 (*((volatile unsigned int *) 0x4002C138)) //D +#define IOCON_P2_15 (*((volatile unsigned int *) 0x4002C13C)) //D +#define IOCON_P2_16 (*((volatile unsigned int *) 0x4002C140)) //D +#define IOCON_P2_17 (*((volatile unsigned int *) 0x4002C144)) //D +#define IOCON_P2_18 (*((volatile unsigned int *) 0x4002C148)) //D +#define IOCON_P2_19 (*((volatile unsigned int *) 0x4002C14C)) //D +#define IOCON_P2_20 (*((volatile unsigned int *) 0x4002C150)) //D +#define IOCON_P2_21 (*((volatile unsigned int *) 0x4002C154)) //D +#define IOCON_P2_22 (*((volatile unsigned int *) 0x4002C158)) //D +#define IOCON_P2_23 (*((volatile unsigned int *) 0x4002C15C)) //D +#define IOCON_P2_24 (*((volatile unsigned int *) 0x4002C160)) //D +#define IOCON_P2_25 (*((volatile unsigned int *) 0x4002C164)) //D +#define IOCON_P2_26 (*((volatile unsigned int *) 0x4002C168)) //D +#define IOCON_P2_27 (*((volatile unsigned int *) 0x4002C16C)) //D +#define IOCON_P2_28 (*((volatile unsigned int *) 0x4002C170)) //D +#define IOCON_P2_29 (*((volatile unsigned int *) 0x4002C174)) //D +#define IOCON_P2_30 (*((volatile unsigned int *) 0x4002C178)) //D +#define IOCON_P2_31 (*((volatile unsigned int *) 0x4002C17C)) //D + +//Port 3 +#define IOCON_P3_0 (*((volatile unsigned int *) 0x4002C180)) //D (IOCON type) +#define IOCON_P3_1 (*((volatile unsigned int *) 0x4002C184)) //D +#define IOCON_P3_2 (*((volatile unsigned int *) 0x4002C188)) //D +#define IOCON_P3_3 (*((volatile unsigned int *) 0x4002C18C)) //D +#define IOCON_P3_4 (*((volatile unsigned int *) 0x4002C190)) //D +#define IOCON_P3_5 (*((volatile unsigned int *) 0x4002C194)) //D +#define IOCON_P3_6 (*((volatile unsigned int *) 0x4002C198)) //D +#define IOCON_P3_7 (*((volatile unsigned int *) 0x4002C19C)) //D +#define IOCON_P3_8 (*((volatile unsigned int *) 0x4002C1A0)) //D +#define IOCON_P3_9 (*((volatile unsigned int *) 0x4002C1A4)) //D +#define IOCON_P3_10 (*((volatile unsigned int *) 0x4002C1A8)) //D +#define IOCON_P3_11 (*((volatile unsigned int *) 0x4002C1AC)) //D +#define IOCON_P3_12 (*((volatile unsigned int *) 0x4002C1B0)) //D +#define IOCON_P3_13 (*((volatile unsigned int *) 0x4002C1B4)) //D +#define IOCON_P3_14 (*((volatile unsigned int *) 0x4002C1B8)) //D +#define IOCON_P3_15 (*((volatile unsigned int *) 0x4002C1BC)) //D +#define IOCON_P3_16 (*((volatile unsigned int *) 0x4002C1C0)) //D +#define IOCON_P3_17 (*((volatile unsigned int *) 0x4002C1C4)) //D +#define IOCON_P3_18 (*((volatile unsigned int *) 0x4002C1C8)) //D +#define IOCON_P3_19 (*((volatile unsigned int *) 0x4002C1CC)) //D +#define IOCON_P3_20 (*((volatile unsigned int *) 0x4002C1D0)) //D +#define IOCON_P3_21 (*((volatile unsigned int *) 0x4002C1D4)) //D +#define IOCON_P3_22 (*((volatile unsigned int *) 0x4002C1D8)) //D +#define IOCON_P3_23 (*((volatile unsigned int *) 0x4002C1DC)) //D +#define IOCON_P3_24 (*((volatile unsigned int *) 0x4002C1E0)) //D +#define IOCON_P3_25 (*((volatile unsigned int *) 0x4002C1E4)) //D +#define IOCON_P3_26 (*((volatile unsigned int *) 0x4002C1E8)) //D +#define IOCON_P3_27 (*((volatile unsigned int *) 0x4002C1EC)) //D +#define IOCON_P3_28 (*((volatile unsigned int *) 0x4002C1F0)) //D +#define IOCON_P3_29 (*((volatile unsigned int *) 0x4002C1F4)) //D +#define IOCON_P3_30 (*((volatile unsigned int *) 0x4002C1F8)) //D +#define IOCON_P3_31 (*((volatile unsigned int *) 0x4002C1FC)) //D + +//Port 4 +#define IOCON_P4_0 (*((volatile unsigned int *) 0x4002C200)) //D (IOCON type) +#define IOCON_P4_1 (*((volatile unsigned int *) 0x4002C204)) //D +#define IOCON_P4_2 (*((volatile unsigned int *) 0x4002C208)) //D +#define IOCON_P4_3 (*((volatile unsigned int *) 0x4002C20C)) //D +#define IOCON_P4_4 (*((volatile unsigned int *) 0x4002C210)) //D +#define IOCON_P4_5 (*((volatile unsigned int *) 0x4002C214)) //D +#define IOCON_P4_6 (*((volatile unsigned int *) 0x4002C218)) //D +#define IOCON_P4_7 (*((volatile unsigned int *) 0x4002C21C)) //D +#define IOCON_P4_8 (*((volatile unsigned int *) 0x4002C220)) //D +#define IOCON_P4_9 (*((volatile unsigned int *) 0x4002C224)) //D +#define IOCON_P4_10 (*((volatile unsigned int *) 0x4002C228)) //D +#define IOCON_P4_11 (*((volatile unsigned int *) 0x4002C22C)) //D +#define IOCON_P4_12 (*((volatile unsigned int *) 0x4002C230)) //D +#define IOCON_P4_13 (*((volatile unsigned int *) 0x4002C234)) //D +#define IOCON_P4_14 (*((volatile unsigned int *) 0x4002C238)) //D +#define IOCON_P4_15 (*((volatile unsigned int *) 0x4002C23C)) //D +#define IOCON_P4_16 (*((volatile unsigned int *) 0x4002C240)) //D +#define IOCON_P4_17 (*((volatile unsigned int *) 0x4002C244)) //D +#define IOCON_P4_18 (*((volatile unsigned int *) 0x4002C248)) //D +#define IOCON_P4_19 (*((volatile unsigned int *) 0x4002C24C)) //D +#define IOCON_P4_20 (*((volatile unsigned int *) 0x4002C250)) //D +#define IOCON_P4_21 (*((volatile unsigned int *) 0x4002C254)) //D +#define IOCON_P4_22 (*((volatile unsigned int *) 0x4002C258)) //D +#define IOCON_P4_23 (*((volatile unsigned int *) 0x4002C25C)) //D +#define IOCON_P4_24 (*((volatile unsigned int *) 0x4002C260)) //D +#define IOCON_P4_25 (*((volatile unsigned int *) 0x4002C264)) //D +#define IOCON_P4_26 (*((volatile unsigned int *) 0x4002C268)) //D +#define IOCON_P4_27 (*((volatile unsigned int *) 0x4002C26C)) //D +#define IOCON_P4_28 (*((volatile unsigned int *) 0x4002C270)) //D +#define IOCON_P4_29 (*((volatile unsigned int *) 0x4002C274)) //D +#define IOCON_P4_30 (*((volatile unsigned int *) 0x4002C278)) //D +#define IOCON_P4_31 (*((volatile unsigned int *) 0x4002C27C)) //D + +//Port 5 +#define IOCON_P5_0 (*((volatile unsigned int *) 0x4002C280)) //D (IOCON type) +#define IOCON_P5_1 (*((volatile unsigned int *) 0x4002C284)) //D +#define IOCON_P5_2 (*((volatile unsigned int *) 0x4002C288)) //I +#define IOCON_P5_3 (*((volatile unsigned int *) 0x4002C28C)) //I +#define IOCON_P5_4 (*((volatile unsigned int *) 0x4002C290)) //D \ No newline at end of file
diff -r 000000000000 -r 3b7f012600ec LPC4088-pwm.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LPC4088-pwm.h Sat May 02 17:33:44 2015 +0000 @@ -0,0 +1,51 @@ +//definicije registrov za periferijo PWM + +//PWM0 +#define IR (*((volatile unsigned int *) 0x40014000)) +#define TCR (*((volatile unsigned int *) 0x40014004)) +#define TC (*((volatile unsigned int *) 0x40014008)) +#define PR (*((volatile unsigned int *) 0x4001400C)) +#define PC (*((volatile unsigned int *) 0x40014010)) + +#define MCR (*((volatile unsigned int *) 0x40014014)) +#define MR0 (*((volatile unsigned int *) 0x40014018)) +#define MR1 (*((volatile unsigned int *) 0x4001401C)) +#define MR2 (*((volatile unsigned int *) 0x40014020)) +#define MR3 (*((volatile unsigned int *) 0x40014024)) +#define MR4 (*((volatile unsigned int *) 0x40014040)) +#define MR5 (*((volatile unsigned int *) 0x40014044)) +#define MR6 (*((volatile unsigned int *) 0x40014048)) + +#define CCR (*((volatile unsigned int *) 0x40014028)) +#define CR0 (*((volatile unsigned int *) 0x4001402C)) +#define CR1 (*((volatile unsigned int *) 0x40014030)) + +#define PCR (*((volatile unsigned int *) 0x4001404C)) +#define LER (*((volatile unsigned int *) 0x40014050)) +#define CTCR (*((volatile unsigned int *) 0x40014070)) + +/* +//PWM1 +#define IR (*((volatile unsigned int *) 0x40018000)) +#define TCR (*((volatile unsigned int *) 0x40018004)) +#define TC (*((volatile unsigned int *) 0x40018008)) +#define PR (*((volatile unsigned int *) 0x4001800C)) +#define PC (*((volatile unsigned int *) 0x40018010)) + +#define MCR (*((volatile unsigned int *) 0x40018014)) +#define MR0 (*((volatile unsigned int *) 0x40018018)) +#define MR1 (*((volatile unsigned int *) 0x4001801C)) +#define MR2 (*((volatile unsigned int *) 0x40018020)) +#define MR3 (*((volatile unsigned int *) 0x40018024)) +#define MR4 (*((volatile unsigned int *) 0x40018040)) +#define MR5 (*((volatile unsigned int *) 0x40018044)) +#define MR6 (*((volatile unsigned int *) 0x40018048)) + +#define CCR (*((volatile unsigned int *) 0x40018028)) +#define CR0 (*((volatile unsigned int *) 0x4001802C)) +#define CR1 (*((volatile unsigned int *) 0x40018030)) + +#define PCR (*((volatile unsigned int *) 0x4001804C)) +#define LER (*((volatile unsigned int *) 0x40018050)) +#define CTCR (*((volatile unsigned int *) 0x40018070)) +*/ \ No newline at end of file
diff -r 000000000000 -r 3b7f012600ec LPC4088-system.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LPC4088-system.h Sat May 02 17:33:44 2015 +0000 @@ -0,0 +1,4 @@ +//LPC4088 sistemski in clock registri + +#define PCONP (*((volatile unsigned int *) 0x400FC0C4)) +#define RSTCON0 (*((volatile unsigned int *) 0x400FC1CC)) \ No newline at end of file
diff -r 000000000000 -r 3b7f012600ec LPC4088-timer.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LPC4088-timer.h Sat May 02 17:33:44 2015 +0000 @@ -0,0 +1,76 @@ +//definicije registrov za periferijo TIMER + +//timer 0 +/* +#define IR (*((volatile unsigned int *) 0x40004000)) +#define TCR (*((volatile unsigned int *) 0x40004004)) +#define TC (*((volatile unsigned int *) 0x40004008)) +#define PR (*((volatile unsigned int *) 0x4000400C)) +#define PC (*((volatile unsigned int *) 0x40004010)) +#define MCR (*((volatile unsigned int *) 0x40004014)) +#define MR0 (*((volatile unsigned int *) 0x40004018)) +#define MR1 (*((volatile unsigned int *) 0x4000401C)) +#define MR2 (*((volatile unsigned int *) 0x40004020)) +#define MR3 (*((volatile unsigned int *) 0x40004024)) +#define CCR (*((volatile unsigned int *) 0x40004028)) +#define CR0 (*((volatile unsigned int *) 0x4000402C)) +#define CR1 (*((volatile unsigned int *) 0x40004030)) +#define EMR (*((volatile unsigned int *) 0x4000403C)) +#define CTCR (*((volatile unsigned int *) 0x40004070)) +*/ + +//timer 1 +/* +#define IR (*((volatile unsigned int *) 0x40008000)) +#define TCR (*((volatile unsigned int *) 0x40008004)) +#define TC (*((volatile unsigned int *) 0x40008008)) +#define PR (*((volatile unsigned int *) 0x4000800C)) +#define PC (*((volatile unsigned int *) 0x40008010)) +#define MCR (*((volatile unsigned int *) 0x40008014)) +#define MR0 (*((volatile unsigned int *) 0x40008018)) +#define MR1 (*((volatile unsigned int *) 0x4000801C)) +#define MR2 (*((volatile unsigned int *) 0x40008020)) +#define MR3 (*((volatile unsigned int *) 0x40008024)) +#define CCR (*((volatile unsigned int *) 0x40008028)) +#define CR0 (*((volatile unsigned int *) 0x4000802C)) +#define CR1 (*((volatile unsigned int *) 0x40008030)) +#define EMR (*((volatile unsigned int *) 0x4000803C)) +#define CTCR (*((volatile unsigned int *) 0x40008070)) +*/ + +//timer 2 +#define IR (*((volatile unsigned int *) 0x40090000)) +#define TCR (*((volatile unsigned int *) 0x40090004)) +#define TC (*((volatile unsigned int *) 0x40090008)) +#define PR (*((volatile unsigned int *) 0x4009000C)) +#define PC (*((volatile unsigned int *) 0x40090010)) +#define MCR (*((volatile unsigned int *) 0x40090014)) +#define MR0 (*((volatile unsigned int *) 0x40090018)) +#define MR1 (*((volatile unsigned int *) 0x4009001C)) +#define MR2 (*((volatile unsigned int *) 0x40090020)) +#define MR3 (*((volatile unsigned int *) 0x40090024)) +#define CCR (*((volatile unsigned int *) 0x40090028)) +#define CR0 (*((volatile unsigned int *) 0x4009002C)) +#define CR1 (*((volatile unsigned int *) 0x40090030)) +#define EMR (*((volatile unsigned int *) 0x4009003C)) +#define CTCR (*((volatile unsigned int *) 0x40090070)) + + +//timer 3 +/* +#define IR (*((volatile unsigned int *) 0x40094000)) +#define TCR (*((volatile unsigned int *) 0x40094004)) +#define TC (*((volatile unsigned int *) 0x40094008)) +#define PR (*((volatile unsigned int *) 0x4009400C)) +#define PC (*((volatile unsigned int *) 0x40094010)) +#define MCR (*((volatile unsigned int *) 0x40094014)) +#define MR0 (*((volatile unsigned int *) 0x40094018)) +#define MR1 (*((volatile unsigned int *) 0x4009401C)) +#define MR2 (*((volatile unsigned int *) 0x40094020)) +#define MR3 (*((volatile unsigned int *) 0x40094024)) +#define CCR (*((volatile unsigned int *) 0x40094028)) +#define CR0 (*((volatile unsigned int *) 0x4009402C)) +#define CR1 (*((volatile unsigned int *) 0x40094030)) +#define EMR (*((volatile unsigned int *) 0x4009403C)) +#define CTCR (*((volatile unsigned int *) 0x40094070)) +*/
diff -r 000000000000 -r 3b7f012600ec main.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.c Sat May 02 17:33:44 2015 +0000 @@ -0,0 +1,97 @@ +#include "LPC4088-ioconfig.h" +#include "LPC4088-system.h" +#include "LPC4088-gpio.h" +#include "LPC4088-adc.h" + +int main(){ + + //nastavitev P1.13 kot GPIO, no pull-up, no hysteresis, not inverted, standard, push-pull + IOCON_P1_13 &= !(0x67F); + + //pin P1.31 skonfiguriramo kot vhod ADC[5] + IOCON_P1_31 |= 0x3; + + //pin P1.31 skonfiguriramo kot no pullup/pulldown + IOCON_P1_31 &= !(0x3<<4); + + //pin P1.31 skonfiguriramo za ADMODE + IOCON_P1_31 &= !(1<<7); + + //pin P0.23 skonfiguriramo kot vhod ADC[0] + IOCON_P0_23 |= 0x3; + + //pin P0.23 skonfiguriramo kot no pullup/pulldown + IOCON_P0_23 &= !(0x3<<4); + + //pin P0.23 skonfiguriramo za ADMODE + IOCON_P0_23 &= !(1<<7); + + + + //vklop GPIO periferije (nepotrebno) + PCONP |= (1<<15); + + //nastavitev P1.13 kot output + DIR1 |= (1<<13); + + //nastavitev P1.13 maske + MASK1 &= !(1<<13); + + + + + + //vklop ADC periferije + PCONP |= (1<<12); + + //PCLK delimo z 99+1=100 + //CR |= (99<<8); + + //izklopimo ADC interrupte + INTEN &= !(0x1FF); + + //pred izbiro "burst mode" moramo izklopiti konverzijo + CR &= !(0x7<<24); + + //izberemo "burst mode" - konverzija se stalno vrši + //CR |= (1<<16); + + //izberemo "software mode" - konverzija se vrši na ukaz + CR &= !(1<<16); + + //izberemo, kateri kanal bomo brali + //CR |= (1<<5); + //CR &= !(1<<0); + + + while(1){ + + //vklopimo ADC (moramo vklopiti po nastavitvah) + CR |= (1<<21); + + //zaženemo konverzijo + CR |= (0x1<<24); + + //pocakamo na konec konverzije in shranimo rezultat + while( (STAT & (1<<0) ) == 0x0 ); + + //ustavimo konverzijo + CR &= !(0x1<<24); + + unsigned int result = 0; + result = ( (DR0 & 0xFFF0) >> 4); //this clears DONE bit + + //izklopimo ADC + CR &= (1<<21); + + if (result > 0x7FF){ + //prizgemo P1.13 + SET1 |= (1<<13); + } + else{ + //ugasnemo P1.13 + CLR1 |= (1<<13); + } + } +} +
diff -r 000000000000 -r 3b7f012600ec mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Sat May 02 17:33:44 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/8ab26030e058 \ No newline at end of file