alexan_e
Administrator
- Joined
- Mar 16, 2008
- Messages
- 11,888
- Helped
- 2,021
- Reputation
- 4,158
- Reaction score
- 2,031
- Trophy points
- 1,393
- Location
- Greece
- Activity points
- 64,371
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 // P0.0: TXD0 (Transmitter output for UART0) // P0.1: RxD0 (Receiver input for UART0) // P0.2: PORT0.2 (General purpose I/O) Output // P0.3: PORT0.3 (General purpose I/open-drain O) Output // P0.4: PORT0.4 (General purpose I/open-drain O) Output // P0.5: PORT0.5 (General purpose I/O) Output // P0.6: AD1.0 (A/D converter 1 input 0) // P0.7: EINT2 (External interrupt 2 input) // P0.8: PORT0.8 (General purpose I/O) Input // P0.9: PORT0.9 (General purpose I/O) Input // P0.10: PORT0.10 (General purpose I/O) Input // P0.11: PORT0.11 (General purpose I/O) Input // P0.12: PORT0.12 (General purpose I/O) Input // P0.13: PORT0.13 (General purpose I/O) Input // P0.14: PORT0.14 (General purpose I/O) Input // P0.15: PORT0.15 (General purpose I/O) Input // P0.16: PORT0.16 (General purpose I/O) Input // P0.17: PORT0.17 (General purpose I/O) Input // P0.18: PORT0.18 (General purpose I/O) Input // P0.19: PORT0.19 (General purpose I/O) Input // P0.20: PORT0.20 (General purpose I/O) Input // P0.21: PORT0.21 (General purpose I/O) Input // P0.22: PORT0.22 (General purpose I/O) Input // P0.23: PORT0.23 (General purpose I/O) Input // P0.25: PORT0.25 (General purpose I/O) Input // P0.26: PORT0.26 (General purpose I/O) Input // P0.27: PORT0.27 (General purpose I/O) Input // P0.28: PORT0.28 (General purpose I/O) Input // P0.29: PORT0.29 (General purpose I/O) Input // P0.30: PORT0.30 (General purpose I/O) Input // P0.31: PORT0.31 (General purpose O) Output // P1.16: PORT1.16 (General purpose I/O) Input // P1.17: PORT1.17 (General purpose I/O) Input // P1.18: PORT1.18 (General purpose I/O) Input // P1.19: PORT1.19 (General purpose I/O) Input // P1.20: PORT1.20 (General purpose I/O) Input // P1.21: PORT1.21 (General purpose I/O) Input // P1.22: PORT1.22 (General purpose I/O) Input // P1.23: PORT1.23 (General purpose I/O) Input // P1.24: PORT1.24 (General purpose I/O) Input // P1.25: POR11.25 (General purpose I/O) Input // P1.26: PORT1.26 (General purpose I/O) Input // P1.27: PORT1.27 (General purpose I/O) Input // P1.28: PORT1.28 (General purpose I/O) Input // P1.29: PORT1.29 (General purpose I/O) Input // P1.30: PORT1.30 (General purpose I/O) Input // P1.31: PORT1.31 (General purpose I/O) Input PINSEL0=0x0000F005; // 0b00000000000000001111000000000101 IO0DIR=0x8000003C; // 0b10000000000000000000000000111100 PINSEL1=0x00000000; // 0b00000000000000000000000000000000 PINSEL2=0x00000000; // 0b00000000000000000000000000000000 IO1DIR=0x00000000; // 0b00000000000000000000000000000000
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 #include <LPC213x.h> /****************************************************************************** EINT0 FAST interrupt service function ******************************************************************************/ __irq void FIQ_Handler (void) { // write code here EXTINT |= 1; // Clear EINT0 interrupt flag VICVectAddr = 0; /* Acknowledge Interrupt */ } APPLY THE FOLLOWING SO THAT FIQ WORKS PROPERLY /********************************************************************************************************** COMMENT THIS LINE IN THE STARTUP FILE USING A SEMICOLON ";" ---> ";FIQ_Handler B FIQ_Handler" ADD THE FOLLOWING LINE IN THE STARTUP CODE DIRECTLY ABOVE THE "Reset_Addr DCD Reset_Handler" IMPORT FIQ_Handler ;<---- add this line and use space in front of it **********************************************************************************************************/ /****************************************************************************** EINT1 interrupt service function ******************************************************************************/ __irq void EINT1_int (void) { // write code here EXTINT |= 2; // Clear EINT1 interrupt flag VICVectAddr = 0; /* Acknowledge Interrupt */ } /****************************************************************************** EINT2 interrupt service function ******************************************************************************/ __irq void EINT2_int (void) { // write code here EXTINT |= 4; // Clear EINT2 interrupt flag VICVectAddr = 0; /* Acknowledge Interrupt */ } /****************************************************************************** WDT interrupt service function ******************************************************************************/ __irq void WDT_int (void) { // write code here VICVectAddr = 0; /* Acknowledge Interrupt */ } /****************************************************************************** EINT3 interrupt service function ******************************************************************************/ __irq void EINT3_int (void) { // write code here EXTINT |= 8; // Clear EINT3 interrupt flag VICVectAddr = 0; /* Acknowledge Interrupt */ } /****************************************************************************** UART0 interrupt service function ******************************************************************************/ __irq void UART0_int (void) { // write code here VICVectAddr = 0; /* Acknowledge Interrupt */ } /* Default Interrupt Function: may be called when ISR is disabled */ __irq void DefISR (void) { } int main(void) { // P0.0: TXD0 (Transmitter output for UART0) // P0.1: RxD0 (Receiver input for UART0) // P0.2: PORT0.2 (General purpose I/O) Input // P0.3: PORT0.3 (General purpose I/open-drain O) Input // P0.4: PORT0.4 (General purpose I/open-drain O) Output // P0.5: PORT0.5 (General purpose I/O) Input // P0.6: PORT0.6 (General purpose I/O) Output // P0.7: PORT0.7 (General purpose I/O) Output // P0.8: PORT0.8 (General purpose I/O) Input // P0.9: EINT3 (External interrupt 3 input) // P0.10: PORT0.10 (General purpose I/O) Input // P0.11: PORT0.11 (General purpose I/O) Input // P0.12: PORT0.12 (General purpose I/O) Output // P0.13: PORT0.13 (General purpose I/O) Input // P0.14: EINT1 (External interrupt 1 input) // P0.15: EINT2 (External interrupt 2 input) // P0.16: PORT0.16 (General purpose I/O) Input // P0.17: PORT0.17 (General purpose I/O) Input // P0.18: PORT0.18 (General purpose I/O) Input // P0.19: PORT0.19 (General purpose I/O) Input // P0.20: PORT0.20 (General purpose I/O) Input // P0.21: PORT0.21 (General purpose I/O) Input // P0.22: PORT0.22 (General purpose I/O) Input // P0.23: PORT0.23 (General purpose I/O) Input // P0.25: PORT0.25 (General purpose I/O) Input // P0.26: PORT0.26 (General purpose I/O) Input // P0.27: PORT0.27 (General purpose I/O) Input // P0.28: PORT0.28 (General purpose I/O) Input // P0.29: PORT0.29 (General purpose I/O) Input // P0.30: PORT0.30 (General purpose I/O) Input // P0.31: PORT0.31 (General purpose O) Output // P1.16: PORT1.16 (General purpose I/O) Input // P1.17: PORT1.17 (General purpose I/O) Input // P1.18: PORT1.18 (General purpose I/O) Input // P1.19: PORT1.19 (General purpose I/O) Input // P1.20: PORT1.20 (General purpose I/O) Input // P1.21: PORT1.21 (General purpose I/O) Input // P1.22: PORT1.22 (General purpose I/O) Input // P1.23: PORT1.23 (General purpose I/O) Input // P1.24: PORT1.24 (General purpose I/O) Input // P1.25: POR11.25 (General purpose I/O) Input // P1.26: PORT1.26 (General purpose I/O) Input // P1.27: PORT1.27 (General purpose I/O) Input // P1.28: PORT1.28 (General purpose I/O) Input // P1.29: PORT1.29 (General purpose I/O) Input // P1.30: PORT1.30 (General purpose I/O) Input // P1.31: PORT1.31 (General purpose I/O) Input PINSEL0=0xA00C0005; // binary: 10100000_00001100_00000000_00000101 IO0DIR=0x800010D0; // binary: 10000000_00000000_00010000_11010000 PINSEL1=0x00000000; // binary: 00000000_00000000_00000000_00000000 PINSEL2=0x00000000; // binary: 00000000_00000000_00000000_00000000 IO1DIR=0x00000000; // binary: 00000000_00000000_00000000_00000000 VICIntSelect |= (1<<14); /* Set EINT0 as FAST Interrupt */ VICIntEnable |= (1<<14); /* Enable EINT0 FAST Interrupt */ VICVectAddr0 = (unsigned long) EINT1_int; /* set interrupt vector 0 */ VICVectCntl0 = ( 0x20 | 15 ); /* enable slot & use it for EINT1 Interrupt */ VICIntEnable |= (1<<15); /* Enable EINT1 Interrupt */ VICVectAddr1 = (unsigned long) EINT2_int; /* set interrupt vector 1 */ VICVectCntl1 = ( 0x20 | 16 ); /* enable slot & use it for EINT2 Interrupt */ VICIntEnable |= (1<<16); /* Enable EINT2 Interrupt */ VICVectAddr2 = (unsigned long) WDT_int; /* set interrupt vector 2 */ VICVectCntl2 = ( 0x20 | 0 ); /* enable slot & use it for WDT Interrupt */ VICIntEnable |= (1<<0); /* Enable WDT Interrupt */ VICVectAddr3 = (unsigned long) EINT3_int; /* set interrupt vector 3 */ VICVectCntl3 = ( 0x20 | 17 ); /* enable slot & use it for EINT3 Interrupt */ VICIntEnable |= (1<<17); /* Enable EINT3 Interrupt */ VICVectAddr4 = (unsigned long) UART0_int; /* set interrupt vector 4 */ VICVectCntl4 = ( 0x20 | 6 ); /* enable slot & use it for UART0 Interrupt */ VICIntEnable |= (1<<6); /* Enable UART0 Interrupt */ VICDefVectAddr = (unsigned long) DefISR; /* un-assigned VIC interrupts */ while(1) { } }
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 /****************************************************************************** ADC0 ******************************************************************************* ADC operational ADC clk: 2500000 Hz ADC rate: 227272,7 samples/sec manual mode, 11 clocks / 10 bit accuracy Start conversion now. Channel 0 dissabled, no interrupt Channel 1 enabled, will generate an interrupt when conversion ends Channel 2 dissabled, no interrupt Channel 3 dissabled, no interrupt Channel 4 dissabled, no interrupt Channel 5 dissabled, no interrupt Channel 6 dissabled, no interrupt Channel 7 dissabled, no interrupt */ AD0CR=0x01200502; /* binary: 00000001_00100000_00000101_00000010 */ AD0INTEN=0x00000002; /* binary: 00000000_00000000_00000000_00000010 */
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 /****************************************************************************** External interrupts ******************************************************************************* Ext. interrupt 0 mode: Level sensitivity / Active low / wake on interrupt 0 is Off Ext. interrupt 2 mode: Edge sensitivity / Rising edge / wake on interrupt 2 is Off */ EXTMODE=0x04; /* binary: 00000100 */ EXTPOLAR=0x04; /* binary: 00000100 */ INTWAKE=0x0000; /* binary: 00000000_00000000 */ EXTINT=0x05; /* clear all the external interrupt flags */ /****************************************************************************** Timer0 (32bit) ******************************************************************************* Counter Enabled, Counter Reset=0 Timer mode: count on rising edge of PCLK Counter clk: 15 MHz, Counts every: 66,67 ns (calculated with peripheral clock:15MHz) MCR0.1 : reset, stop, generate interrupt on complare match MCR0.3 : reset, on complare match CCR0.0 : capture on rising edge, capture on falling edge, CCR0.2 : capture on rising edge, capture on falling edge, generate interrupt on capture event, MAT0.0 : On compare match Set bit/output */ T0TCR=0x01; /* binary: 00000001 */ T0CTCR=0x00; /* binary: 00000000 */ T0TC=0x00000000; /* decimal 0 */ T0PR=0x00000000; /* decimal 0 */ T0PC=0x00000000; /* decimal 0 */ T0MCR=0x0438; /* binary: 00000100_00111000 */ T0MR0=0x00000000; /* decimal 0 */ T0MR1=0x00000208; /* decimal 520 */ T0MR2=0x00000000; /* decimal 0 */ T0MR3=0x000000C8; /* decimal 200 */ T0CCR=0x01C3; /* binary: 00000001_11000011 */ T0EMR=0x0021; /* binary: 00000000_00100001 */ PWM0CON=0x00000000; /* binary: 00000000_00000000_00000000_00000000 */ /****************************************************************************** Timer1 (32bit) ******************************************************************************* Counter Enabled, Counter Reset=0 Timer mode: count on rising edge of PCLK Counter clk: 576,9231 KHz, Counts every: 1,73 us (calculated with peripheral clock:15MHz) MCR1.1 : reset, generate interrupt on complare match CCR1.2 : capture on falling edge, generate interrupt on capture event, CCR1.3 : capture on rising edge, capture on falling edge, */ T1TCR=0x01; /* binary: 00000001 */ T1CTCR=0x00; /* binary: 00000000 */ T1TC=0x00000000; /* decimal 0 */ T1PR=0x00000019; /* decimal 25 */ T1PC=0x00000000; /* decimal 0 */ T1MCR=0x0018; /* binary: 00000000_00011000 */ T1MR0=0x00000064; /* decimal 100 */ T1MR1=0x000000C8; /* decimal 200 */ T1MR2=0x00000000; /* decimal 0 */ T1MR3=0x00000000; /* decimal 0 */ T1CCR=0x0780; /* binary: 00000111_10000000 */ T1EMR=0x0000; /* binary: 00000000_00000000 */ PWM1CON=0x00000000; /* binary: 00000000_00000000_00000000_00000000 */
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 /****************************************************************************** PWM1 ******************************************************************************* Counter Enabled, Counter Reset=0, PWM mode enabled Timer mode: count on rising edge of PCLK Counter clk: 15 MHz, Counts every: 66,67 ns (calculated with peripheral clock: 15MHz) MCR1.0 : reset, on compare match PWM frequency: 50 KHz PWM1: Single edge, set by MR0, reset by MR1, output enabled PWM2: Single edge, set by MR0, reset by MR2, output disabled PWM3: Single edge, set by MR0, reset by MR3, output disabled PWM4: Double edge, set by MR3, reset by MR4, output enabled PWM5: Single edge, set by MR0, reset by MR5, output disabled PWM6: Single edge, set by MR0, reset by MR6, output disabled */ PWM1TC=0x00000000; /* decimal 0 */ PWM1PR=0x00000000; /* decimal 0 */ PWM1MCR=0x00000002; /* binary: 00000000_00000000_00000000_00000010 */ PWM1MR0=0x0000012C; /* decimal 300 */ PWM1MR1=0x00000096; /* decimal 150 */ PWM1MR2=0x00000000; /* decimal 0 */ PWM1MR3=0x00000020; /* decimal 32 */ PWM1MR4=0x00000030; /* decimal 48 */ PWM1MR5=0x00000000; /* decimal 0 */ PWM1MR6=0x00000000; /* decimal 0 */ PWM1CTCR=0x00; /* binary: 00000000 */ PWM1CCR=0x00000000; /* binary: 00000000_00000000_00000000_00000000 */ PWM1PCR=0x00001210; /* binary: 00000000_00000000_00010010_00010000 */ PWM1TCR=0x09; /* binary: 00001001 */
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 /************************************************************************************ Code created using the ARMwizard, visit **broken link removed** ************************************************************************************/ #include <LPC17xx.h> /****************************************************************************** TIMER0 interrupt service function ******************************************************************************/ __irq void TIMER0_IRQHandler(void) { /* write code here */ /* list of all available flags, select which to use */ LPC_TIM0->IR = 1; /* Clear MAT0.0 interrupt flag */ LPC_TIM0->IR = 2; /* Clear MAT0.1 interrupt flag */ LPC_TIM0->IR = 4; /* Clear MAT0.2 interrupt flag */ LPC_TIM0->IR = 8; /* Clear MAT0.3 interrupt flag */ LPC_TIM0->IR = 16; /* Clear CAP0.0 interrupt flag */ LPC_TIM0->IR = 32; /* Clear CAP0.1 interrupt flag */ } /****************************************************************************** EINT0 interrupt service function ******************************************************************************/ __irq void EINT0_IRQHandler(void) { /* write code here */ LPC_SC->EXTINT = 1; /* Clear EINT0 interrupt flag */ } /****************************************************************************** SPI interrupt service function ******************************************************************************/ __irq void SPI_IRQHandler(void) { /* write code here */ LPC_SPI->SPINT = 1; /* Clear SPI interrupt flag */ } int main(void) { /* P0.0: PORT0.0 (General purpose I/O) Output, pull-up resistor enabled P0.1: PORT0.1 (General purpose I/O) Output, pull-up resistor enabled P0.2: PORT0.2 (General purpose I/O) Input, repeater mode P0.3: PORT0.3 (General purpose I/O) Input, repeater mode, open drain P0.4: PORT0.4 (General purpose I/O) Input, pull-up resistor enabled P0.5: PORT0.5 (General purpose I/O) Input, pull-up resistor enabled P0.6: PORT0.6 (General purpose I/O) Input, neither pull-up nor pull-down P0.7: PORT0.7 (General purpose I/O) Input, neither pull-up nor pull-down P0.8: PORT0.8 (General purpose I/O) Input, pull-down resistor enabled, open drain P0.9: PORT0.9 (General purpose I/O) Input, pull-up resistor enabled P0.10: PORT0.10 (General purpose I/O) Input, pull-up resistor enabled P0.11: PORT0.11 (General purpose I/O) Input, pull-up resistor enabled P0.15: PORT0.15 (General purpose I/O) Input, pull-up resistor enabled P0.16: PORT0.16 (General purpose I/O) Input, pull-up resistor enabled, open drain P0.17: PORT0.17 (General purpose I/O) Input, pull-up resistor enabled P0.18: PORT0.18 (General purpose I/O) Input, pull-up resistor enabled P0.19: PORT0.19 (General purpose I/O) Input, pull-up resistor enabled P0.20: PORT0.20 (General purpose I/O) Input, pull-up resistor enabled P0.21: PORT0.21 (General purpose I/O) Input, pull-up resistor enabled P0.22: PORT0.22 (General purpose I/O) Input, pull-up resistor enabled P0.23: PORT0.23 (General purpose I/O) Input, pull-up resistor enabled P0.24: PORT0.24 (General purpose I/O) Input, pull-up resistor enabled P0.25: PORT0.25 (General purpose I/O) Input, pull-up resistor enabled P0.26: PORT0.26 (General purpose I/O) Input, pull-up resistor enabled P0.27: PORT0.27 (General purpose I/open-drain O) Input P0.28: PORT0.28 (General purpose I/open-drain O) Input P0.29: PORT0.29 (General purpose I/O) Input P0.30: PORT0.30 (General purpose I/O) Input P1.0: PORT1.0 (General purpose I/O) Input, pull-up resistor enabled P1.1: PORT1.1 (General purpose I/O) Input, pull-up resistor enabled P1.4: PORT1.4 (General purpose I/O) Input, pull-up resistor enabled P1.8: PORT1.8 (General purpose I/O) Input, pull-up resistor enabled P1.9: PORT1.9 (General purpose I/O) Input, pull-up resistor enabled P1.10: PORT1.10 (General purpose I/O) Input, pull-up resistor enabled P1.14: PORT1.14 (General purpose I/O) Input, pull-up resistor enabled P1.15: PORT1.15 (General purpose I/O) Input, pull-up resistor enabled P1.16: PORT1.16 (General purpose I/O) Input, pull-up resistor enabled P1.17: PORT1.17 (General purpose I/O) Input, pull-up resistor enabled P1.18: PORT1.18 (General purpose I/O) Input, pull-up resistor enabled P1.19: PORT1.19 (General purpose I/O) Input, pull-up resistor enabled P1.20: PORT1.20 (General purpose I/O) Input, pull-up resistor enabled P1.21: PORT1.21 (General purpose I/O) Input, pull-up resistor enabled P1.22: PORT1.22 (General purpose I/O) Input, pull-up resistor enabled P1.23: PORT1.23 (General purpose I/O) Input, pull-up resistor enabled P1.24: PORT1.24 (General purpose I/O) Input, pull-up resistor enabled P1.25: PORT1.25 (General purpose I/O) Input, pull-up resistor enabled P1.26: PORT1.26 (General purpose I/O) Input, pull-up resistor enabled P1.27: PORT1.27 (General purpose I/O) Input, pull-up resistor enabled P1.28: PORT1.28 (General purpose I/O) Input, pull-up resistor enabled P1.29: PORT1.29 (General purpose I/O) Input, pull-up resistor enabled P1.30: PORT1.30 (General purpose I/O) Input, pull-up resistor enabled P1.31: PORT1.31 (General purpose I/O) Input, pull-up resistor enabled P2.0: PORT2.0 (General purpose I/O) Input, pull-up resistor enabled P2.1: PORT2.1 (General purpose I/O) Input, pull-up resistor enabled P2.2: PORT2.2 (General purpose I/O) Input, pull-up resistor enabled P2.3: PORT2.3 (General purpose I/O) Input, pull-up resistor enabled P2.4: PORT2.4 (General purpose I/O) Input, pull-up resistor enabled P2.5: PORT2.5 (General purpose I/O) Input, pull-up resistor enabled P2.6: PORT2.6 (General purpose I/O) Input, pull-up resistor enabled P2.7: PORT2.7 (General purpose I/O) Input, pull-up resistor enabled P2.8: PORT2.8 (General purpose I/O) Input, pull-up resistor enabled P2.9: PORT2.9 (General purpose I/O) Input, pull-up resistor enabled P2.10: PORT2.10 (General purpose I/O) Input, pull-up resistor enabled P2.11: PORT2.11 (General purpose I/O) Input, pull-up resistor enabled P2.12: PORT2.12 (General purpose I/O) Input, pull-up resistor enabled P2.13: PORT2.13 (General purpose I/O) Input, pull-up resistor enabled P3.25: PORT3.25 (General purpose I/O) Input, pull-up resistor enabled P3.26: PORT3.26 (General purpose I/O) Input, pull-up resistor enabled P4.28: PORT4.28 (General purpose I/O) Input, pull-up resistor enabled P4.29: PORT4.29 (General purpose I/O) Input, pull-up resistor enabled */ LPC_PINCON->PINSEL0=0x00000000; /* binary: 00000000_00000000_00000000_00000000 */ LPC_PINCON->PINMODE0=0x0003A050; /* binary: 00000000_00000011_10100000_01010000 */ LPC_GPIO0->FIODIR=0x00000003; /* binary: 00000000_00000000_00000000_00000011 */ LPC_PINCON->PINMODE_OD0=0x00010108; /* binary: 00000000_00000001_00000001_00001000 */ LPC_PINCON->PINSEL1=0x00000000; /* binary: 00000000_00000000_00000000_00000000 */ LPC_PINCON->PINMODE1=0x00000000; /* binary: 00000000_00000000_00000000_00000000 */ LPC_PINCON->PINSEL2=0x00000000; /* binary: 00000000_00000000_00000000_00000000 */ LPC_PINCON->PINMODE2=0x00000000; /* binary: 00000000_00000000_00000000_00000000 */ LPC_GPIO1->FIODIR=0x00000000; /* binary: 00000000_00000000_00000000_00000000 */ LPC_PINCON->PINMODE_OD1=0x00000000; /* binary: 00000000_00000000_00000000_00000000 */ LPC_PINCON->PINSEL3=0x00000000; /* binary: 00000000_00000000_00000000_00000000 */ LPC_PINCON->PINMODE3=0x00000000; /* binary: 00000000_00000000_00000000_00000000 */ LPC_PINCON->PINSEL4=0x00000000; /* binary: 00000000_00000000_00000000_00000000 */ LPC_PINCON->PINMODE4=0x00000000; /* binary: 00000000_00000000_00000000_00000000 */ LPC_GPIO2->FIODIR=0x00000000; /* binary: 00000000_00000000_00000000_00000000 */ LPC_PINCON->PINMODE_OD2=0x00000000; /* binary: 00000000_00000000_00000000_00000000 */ LPC_PINCON->PINSEL7=0x00000000; /* binary: 00000000_00000000_00000000_00000000 */ LPC_PINCON->PINMODE7=0x00000000; /* binary: 00000000_00000000_00000000_00000000 */ LPC_GPIO3->FIODIR=0x00000000; /* binary: 00000000_00000000_00000000_00000000 */ LPC_PINCON->PINMODE_OD3=0x00000000; /* binary: 00000000_00000000_00000000_00000000 */ LPC_PINCON->PINSEL9=0x00000000; /* binary: 00000000_00000000_00000000_00000000 */ LPC_PINCON->PINMODE9=0x00000000; /* binary: 00000000_00000000_00000000_00000000 */ LPC_GPIO4->FIODIR=0x00000000; /* binary: 00000000_00000000_00000000_00000000 */ LPC_PINCON->PINMODE_OD4=0x00000000; /* binary: 00000000_00000000_00000000_00000000 */ /****************************************************************************** External interrupts ******************************************************************************* Ext. interrupt 0 mode: Edge sensitivity / Rising edge */ LPC_SC->EXTMODE=0x01; /* binary: 00000001 */ LPC_SC->EXTPOLAR=0x01; /* binary: 00000001 */ LPC_SC->EXTINT=0x01; /* clear the external interrupt flags */ /****************************************************************************** GPIO interrupts ******************************************************************************* P0.0 : On falling edge P0.1 : On falling edge P0.4 : On both edges P0.6 : On rising edge */ LPC_GPIOINT->IO0IntEnR=0x00000050; /* binary: 00000000_00000000_00000000_01010000 */ LPC_GPIOINT->IO0IntEnF=0x00000013; /* binary: 00000000_00000000_00000000_00010011 */ LPC_GPIOINT->IO2IntEnR=0x00000000; /* binary: 00000000_00000000_00000000_00000000 */ LPC_GPIOINT->IO2IntEnF=0x00000000; /* binary: 00000000_00000000_00000000_00000000 */ /****************************************************************************** Vectored Interrupt initialization ******************************************************************************/ NVIC_EnableIRQ(TIMER0_IRQn); /* Enable TIMER0 interrupt */ NVIC_SetPriority(TIMER0_IRQn,0); /* Default priority group 0, can be 0(highest) - 31(lowest) */ NVIC_EnableIRQ(EINT0_IRQn); /* Enable EINT0 interrupt */ NVIC_SetPriority(EINT0_IRQn,0); /* Default priority group 0, can be 0(highest) - 31(lowest) */ NVIC_EnableIRQ(SPI_IRQn); /* Enable SPI interrupt */ NVIC_SetPriority(SPI_IRQn,0); /* Default priority group 0, can be 0(highest) - 31(lowest) */ /****************************************************************************** ADC0 ******************************************************************************* ADC operational ADC clk: 3 MHz (calculated with peripheral clock: 15MHz) ADC rate: 46,1538 Ksamples/sec manual mode, 60 clocks / 12 bit accuracy No start (only in manual mode, for burst always on) Channel 0 enabled, global DONE flag in ADGDR will generate an interrupt Channel 1 disabled, global DONE flag in ADGDR will generate an interrupt Channel 2 disabled, global DONE flag in ADGDR will generate an interrupt Channel 3 disabled, global DONE flag in ADGDR will generate an interrupt Channel 4 disabled, global DONE flag in ADGDR will generate an interrupt Channel 5 disabled, global DONE flag in ADGDR will generate an interrupt Channel 6 disabled, global DONE flag in ADGDR will generate an interrupt Channel 7 disabled, global DONE flag in ADGDR will generate an interrupt */ LPC_SC->PCONP |= 0x1000; /* Enable peripheral clock for ADC (default is disabled) */ LPC_ADC->ADCR=0x00200401; /* binary: 00000000_00100000_00000100_00000001 */ LPC_ADC->ADINTEN=0x00000100; /* binary: 00000000_00000000_00000001_00000000 */ /****************************************************************************** Timer0 (32bit) ******************************************************************************* Counter Disabled, Counter Reset=0 Timer mode: count on rising edge of PCLK Counter clk: 2 MHz, Counts every: 500 ns (calculated with peripheral clock: 30MHz) MCR0.0 : generate interrupt on compare match */ LPC_TIM0->CTCR=0x00; /* binary: 00000000 */ LPC_TIM0->TC=0x00000000; /* decimal 0 */ LPC_TIM0->PR=0x0000000E; /* decimal 14 */ LPC_TIM0->MCR=0x0001; /* binary: 00000000_00000001 */ LPC_TIM0->MR0=0x000000C8; /* decimal 200 */ LPC_TIM0->MR1=0x00000000; /* decimal 0 */ LPC_TIM0->MR2=0x00000000; /* decimal 0 */ LPC_TIM0->MR3=0x00000000; /* decimal 0 */ LPC_TIM0->CCR=0x0000; /* binary: 00000000_00000000 */ LPC_TIM0->EMR=0x0000; /* binary: 00000000_00000000 */ LPC_TIM0->TCR=0x00; /* binary: 00000000 */ while(1) { } }
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?