Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <hidef.h> /* for EnableInterrupts macro */
- #include "derivative.h" /* include peripheral declarations */
- #include "init.h" // Include the header file that includes I/O definitions
- volatile unsigned int counter = 0;
- unsigned char dummy = 0;
- typedef union
- {
- unsigned char LEDs;
- struct
- {
- unsigned char bit0 :1;
- unsigned char bit1 :1;
- unsigned char bit2 :1;
- unsigned char bit3 :1;
- unsigned char bit4 :1;
- unsigned char bit5 :1;
- unsigned char bit6 :1;
- unsigned char bit7 :1;
- } bits;
- } _LED_register;
- _LED_register LED_register;
- interrupt VectorNumber_Vmtim0 void MTIM0_ISR(void)
- {
- // Dummily read MTIMx_SC register and
- // then write a 0 to MTIMxSC[TOF]
- MTIM0_overflow = MTIM0_stop;
- LED1 = ~LED1;
- }
- interrupt VectorNumber_Virq_wdog void WDOG_ISR(void)
- {
- touch_LED = 0;
- }
- void updateLEDs(void)
- {
- LED1 = ~LED_register.bits.bit0;
- LED2 = ~LED_register.bits.bit1;
- LED3 = ~LED_register.bits.bit2;
- LED4 = ~LED_register.bits.bit3;
- LED5 = ~LED_register.bits.bit4;
- LED6 = ~LED_register.bits.bit5;
- LED7 = ~LED_register.bits.bit6;
- LED8 = ~LED_register.bits.bit7;
- }
- void main(void)
- {
- EnableInterrupts;
- initialize_CPU();
- initialize_IO();
- LED_ctrl = 1;
- LED5 = 0;
- counter = 0xFFFF;
- while (counter > 0)
- {
- counter--;
- __RESET_WATCHDOG();
- }
- LED_ctrl = 0;
- LED5 = 1;
- counter = 0xFFFF;
- while (counter > 0)
- {
- counter--;
- __RESET_WATCHDOG();
- }
- LED_ctrl = 1;
- LED_register.LEDs = SYS_SRS;
- updateLEDs();
- dummy = 0x05;
- while (dummy > 0)
- {
- counter = 0xFFFF;
- while (counter > 0)
- {
- counter--;
- __RESET_WATCHDOG();
- }
- dummy--;
- }
- LED_ctrl = 0;
- LED_register.LEDs = 0;
- // initialize_MTIM0();
- for (;;)
- {
- LED7 = ~LED7;
- LED8 = ~LED8;
- // __RESET_WATCHDOG(); /* feeds the dog */
- /* loop forever */
- /* please make sure that you never leave main */
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement