1 /******************************************************************************/
2 /* This file is part of the uVision/ARM development tools */
3 /* Copyright KEIL ELEKTRONIK GmbH 2002-2004 */
4 /******************************************************************************/
6 /* PWM.C: LED Flasher */
8 /******************************************************************************/
20 * * Function Name: lowInit()
23 * This function starts up the PLL then sets up the GPIO pins before
24 * waiting for the PLL to lock. It finally engages the PLL and
35 static void lowInit(void)
37 // set PLL multiplier & divisor.
38 // values computed from config.h
39 PLLCFG
= PLLCFG_MSEL
| PLLCFG_PSEL
;
43 PLLFEED
= 0xAA; // Make it happen. These two updates
44 PLLFEED
= 0x55; // MUST occur in sequence.
46 // setup the parallel port pin
47 IOCLR
= PIO_ZERO_BITS
; // clear the ZEROs output
48 IOSET
= PIO_ONE_BITS
; // set the ONEs output
49 IODIR
= PIO_OUTPUT_BITS
; // set the output bit direction
52 while (!(PLLSTAT
& PLLSTAT_LOCK
))
55 // enable & connect PLL
56 PLLCON
= PLLCON_PLLE
| PLLCON_PLLC
;
57 PLLFEED
= 0xAA; // Make it happen. These two updates
58 PLLFEED
= 0x55; // MUST occur in sequence.
60 // setup & enable the MAM
61 MAMTIM
= MAMTIM_CYCLES
;
64 // set the peripheral bus speed
65 // value computed from config.h
66 VPBDIV
= VPBDIV_VALUE
; // set the peripheral bus clock speed
71 * Function Name: sysInit()
74 * This function is responsible for initializing the program
86 static void sysInit(void)
88 lowInit(); // setup clocks and processor port pins
90 // set the interrupt controller defaults
93 MEMMAP
= MEMMAP_SRAM
; // map interrupt vectors space into SRAM
94 #elif defined(ROM_RUN)
95 MEMMAP
= MEMMAP_FLASH
; // map interrupt vectors space into FLASH
97 #error RUN_MODE not defined!
99 VICIntEnClear
= 0xFFFFFFFF; // clear all interrupts
100 VICIntSelect
= 0x00000000; // clear all FIQ selections
101 VICDefVectAddr
= (uint32_t)reset
; // point unvectored IRQs to reset()
108 * @param d duration (unit not defined yet)
115 for (i
= 0; i
< 10; i
++)
123 * this function has been created to test PWM unit
124 * It has been tested with the DC motor of M.Sojka ;-)
125 * One accelerated phase with upward rotation then one constant speed phase with backward rotation
126 * DC motor pin 2 = PWM4
127 * DC motor pin 3 = PWM6
128 * DC motor pin 25 = GND
142 for (j
= 0 ; j
< 10 ; j
++)