ARMwizard โปรแกรมช่วยการตั้งค่า Register MCU ค่าย NXP ตัวโปรแกรม ARMwizard จะสร้ัางค่าเริ่มต้นโค๊ดโปรแกรมให้กับไมโครคอนโทรลเลอร์ที่เราเลือก โดยค่าที่ถูกสร้างขึ้นมาจากการเลือกค่า setting มาจากหน้าต่างโปรแกรม ARMwizard ซึ่ภายในโปรแกรมประกอบไปด้วย การตั้งค่า register , การเซ็ทค่า Interrupt ซึ่งจะทำให้การเขียนโปรแกรมของเราทำงานได้สะดวก และรวดเร็วยิ่งขึ้น
ภายในโปรแกรมประกอบด้วยการตั้งค่าต่อไปนี้
What is new in v2.0.1 & v2.0 • Added profiles for LPC1751/52/54/56/58/59 • Added support for LPC17xx chips, includes LPC1763/64/65/66/67/68/69 mcu profiles • Added pin setting for open drain and repeater mode for LPC17xx • Added GPIO interrupt trigger edge selector to enable interrupts for selected GPIO pins • CLKDIV register of A/D can also be set by target sample rate ( in addition to A/D frequency) • When Timer2 & Timer3 is used the PCONP enable bit is set to enable the timer operation เบอร์ไมโครคอนโทรลเลอร์ที่รองรับ
LPC1751 (NEW)
LPC1752 (NEW)
LPC1754 (NEW)
LPC1756 (NEW)
LPC1758 (NEW)
LPC1759 (NEW)
LPC1763 (NEW)
LPC1764 (NEW)
LPC1765 (NEW)
LPC1766 (NEW)
LPC1767 (NEW)
LPC1768 (NEW)
LPC1769 (NEW)
LPC2101
LPC2102
LPC2103
LPC2104
LPC2105
LPC2106
LPC2131
LPC2132
LPC2134
LPC2136
LPC2138
LPC2141
LPC2142
LPC2144
LPC2146
LPC2148
LPC2361
LPC2362
LPC2364
LPC2365
LPC2366
LPC2367
LPC2368
LPC2377
LPC2378
LPC2387
LPC2388
LPC2420
LPC2458
LPC2460
LPC2468
LPC2470
LPC2478
ตัวอย่างโค๊ดที่ได้จากโปรแกรม ARMwizard สำหรับไมโครคอนโทรลเลอร์เบอร์ LPC21xxx 23xxx, 24xxx
/************************************************************************************ Code created using the ARMwizard, visit http://alexan.edaboard.eu ************************************************************************************/ #include <LPC2103.h> #define PWM0CON T0PWMCON #define PWM1CON T1PWMCON #define PWM2CON T2PWMCON #define PWM3CON T3PWMCON #define AD0CR ADCR #define AD0INTEN ADINTEN #define IO0PIN IOPIN #define IO0SET IOSET #define IO0DIR IODIR #define IO0CLR IOCLR /****************************************************************************** TIMER0 interrupt service function ******************************************************************************/ __irq void TIMER0_int (void) { /* write code here */ /* list of all available flags, select which to use */ T0IR = 1; /* Clear MAT0.0 interrupt flag */ T0IR = 2; /* Clear MAT0.1 interrupt flag */ T0IR = 4; /* Clear MAT0.2 interrupt flag */ T0IR = 8; /* Clear MAT0.3 interrupt flag */ T0IR = 16; /* Clear CAP0.0 interrupt flag */ T0IR = 32; /* Clear CAP0.1 interrupt flag */ T0IR = 64; /* Clear CAP0.2 interrupt flag */ /*T0IR = 128; Clear CAP0.3 interrupt flag, not usable on timer0 */ VICVectAddr = 0; /* Acknowledge Interrupt */ } /****************************************************************************** TIMER1 interrupt service function ******************************************************************************/ __irq void TIMER1_int (void) { /* write code here */ /* list of all available flags, select which to use */ T1IR = 1; /* Clear MAT1.0 interrupt flag */ T1IR = 2; /* Clear MAT1.1 interrupt flag */ T1IR = 4; /* Clear MAT1.2 interrupt flag */ T1IR = 8; /* Clear MAT1.3 interrupt flag */ T1IR = 16; /* Clear CAP1.0 interrupt flag */ T1IR = 32; /* Clear CAP1.1 interrupt flag */ T1IR = 64; /* Clear CAP1.2 interrupt flag */ T1IR = 128; /* Clear CAP1.3 interrupt flag */ VICVectAddr = 0; /* Acknowledge Interrupt */ } /****************************************************************************** EINT0 interrupt service function ******************************************************************************/ __irq void EINT0_int (void) { /* write code here */ EXTINT = 1; /* Clear EINT0 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 */ } /****************************************************************************** AD0 interrupt service function ******************************************************************************/ __irq void AD0_int (void) { /* write code here */ /* read ADC result to clear interrupt flag (done) */ VICVectAddr = 0; /* Acknowledge Interrupt */ } /* Default Interrupt Function: may be called when ISR is disabled */ __irq void DefISR (void) { } int main(void) { /* P0.0: PORT0.0 (General purpose I/O) Input P0.1: PORT0.1 (General purpose I/O) Input P0.2: PORT0.2 (General purpose I/open-drain O) Input P0.3: PORT0.3 (General purpose I/open-drain O) Input P0.4: PORT0.4 (General purpose I/O) Input P0.5: PORT0.5 (General purpose I/O) Input P0.6: PORT0.6 (General purpose I/O) Input P0.7: PORT0.7 (General purpose I/O) 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.24: PORT0.24 (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 */ PINSEL0=0x00000000; /* binary: 00000000_00000000_00000000_00000000 */ IO0DIR=0x80000000; /* binary: 10000000_00000000_00000000_00000000 */ PINSEL1=0x00000000; /* binary: 00000000_00000000_00000000_00000000 */ /****************************************************************************** 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 */ VICVectAddr2 = (unsigned long) TIMER0_int; /* set interrupt vector 2 */ VICVectCntl2 = ( 0x20 | 4 ); /* enable slot & use it for TIMER0 Interrupt */ VICIntEnable |= (1<<4); /* Enable TIMER0 Interrupt */ VICVectAddr3 = (unsigned long) TIMER1_int; /* set interrupt vector 3 */ VICVectCntl3 = ( 0x20 | 5 ); /* enable slot & use it for TIMER1 Interrupt */ VICIntEnable |= (1<<5); /* Enable TIMER1 Interrupt */ VICVectAddr5 = (unsigned long) EINT0_int; /* set interrupt vector 5 */ VICVectCntl5 = ( 0x20 | 14 ); /* enable slot & use it for EINT0 Interrupt */ VICIntEnable |= (1<<14); /* Enable EINT0 Interrupt */ VICVectAddr7 = (unsigned long) EINT2_int; /* set interrupt vector 7 */ VICVectCntl7 = ( 0x20 | 16 ); /* enable slot & use it for EINT2 Interrupt */ VICIntEnable |= (1<<16); /* Enable EINT2 Interrupt */ VICVectAddr10 = (unsigned long) AD0_int; /* set interrupt vector 10 */ VICVectCntl10 = ( 0x20 | 18 ); /* enable slot & use it for AD0 Interrupt */ VICIntEnable |= (1<<18); /* Enable AD0 Interrupt */ VICDefVectAddr = (unsigned long) DefISR; /* un-assigned VIC interrupts */ /****************************************************************************** ADC0 ******************************************************************************* ADC operational ADC clk: 3,75 MHz (calculated with peripheral clock:15MHz) ADC rate: 375 Ksamples/sec burst mode, 10 clocks / 9 bit accuracy No start (only in manual mode, for burst always on) Channel 0 enabled, will generate an interrupt when conversion ends Channel 1 disabled, no interrupt Channel 2 disabled, no interrupt Channel 3 enabled, will generate an interrupt when conversion ends Channel 4 enabled, no interrupt Channel 5 disabled, no interrupt Channel 6 disabled, no interrupt Channel 7 disabled, no interrupt */ AD0CR=0x00230319; /* binary: 00000000_00100011_00000011_00011001 */ AD0INTEN=0x00000009; /* binary: 00000000_00000000_00000000_00001001 */ /****************************************************************************** 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 compare match MCR0.3 : reset, on compare 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 compare 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 */ while(1) { } } ดาวน์โหลดโปรแกรม ARMwizard
เครดิต http://alexan.edaboard.eu/ |