decreased speed for led counter and stop it at the end of main
authorBernhard Urban <lewurm@gmx.net>
Fri, 11 Dec 2009 23:33:26 +0000 (00:33 +0100)
committerBernhard Urban <lewurm@gmx.net>
Fri, 11 Dec 2009 23:33:26 +0000 (00:33 +0100)
MAIN.c
RLT.c
RLT.h

diff --git a/MAIN.c b/MAIN.c
index bdda7bbfcb29fca3d8f5ba140a63558f620a61d4..b5d776ef6fccb270f6bbf726591be8f9320cfc1d 100644 (file)
--- a/MAIN.c
+++ b/MAIN.c
@@ -56,14 +56,14 @@ void main(void)
 
        /*      Enable LEDs     */
        DDR14 = 0xFF;
-       PDR14 = 0x00;
+       PDR14 = 0xff;
 
        /*      Initialize Reload Timer Channel 0       */
        RLT_InitializeTimer(0, RLT_RUMMODE_RELOAD, RLT_CLOCKMODE_DIV32, RLT_TRIGGER_SOFTWARE, RLT_OUTOUTMODE_HIGHLEVEL);
-       RLT_SetReloadValue(0,0x1388);   // CLKP/32, 0.01s Interval => 0x1388 counts
-       RLT_EnableInterrupt(0);
+       RLT_SetReloadValue(0,0xfffe);
        RLT_TriggerTimer(0);
-                
+       RLT_EnableInterrupt(0, 1);
+
        /*      Initialize UART4        */
        InitUart4();
 
@@ -179,6 +179,8 @@ void main(void)
        {
                Puts4("\n********* FLASH Programming Demo done **********\n");
        }
+
+       RLT_EnableInterrupt(0, 0);
                                        
     while(1)                   /* endless loop */
     {    
diff --git a/RLT.c b/RLT.c
index 72d4cf36e11273815af5d1ba8b765999f1a525dd..eadab639ab89db62484d2e9bc4005b5f7e843e4e 100644 (file)
--- a/RLT.c
+++ b/RLT.c
@@ -154,7 +154,7 @@ void RLT_TriggerTimer(unsigned char channel)
        }
 }
 
-void RLT_EnableInterrupt(unsigned char channel)
+void RLT_EnableInterrupt(unsigned char channel, unsigned char enable)
 {
        switch(channel)
        {
@@ -164,7 +164,7 @@ void RLT_EnableInterrupt(unsigned char channel)
                        TMCSR0_UF = 0;
                        
                        /* Enable Interrupt     */
-                       TMCSR0_INTE = 1;
+                       TMCSR0_INTE = enable;
                        break;
                }       
                case 1:
@@ -173,7 +173,7 @@ void RLT_EnableInterrupt(unsigned char channel)
                        TMCSR1_UF = 0;
                        
                        /* Enable Interrupt     */
-                       TMCSR1_INTE = 1;
+                       TMCSR1_INTE = enable;
                        break;
                }       
                case 2:
@@ -182,7 +182,7 @@ void RLT_EnableInterrupt(unsigned char channel)
                        TMCSR2_UF = 0;
                        
                        /* Enable Interrupt     */
-                       TMCSR2_INTE = 1;
+                       TMCSR2_INTE = enable;
                        break;
                }       
                case 3:
@@ -191,7 +191,7 @@ void RLT_EnableInterrupt(unsigned char channel)
                        TMCSR3_UF = 0;
                        
                        /* Enable Interrupt     */
-                       TMCSR3_INTE = 1;
+                       TMCSR3_INTE = enable;
                        break;
                }       
                case 4:
@@ -200,7 +200,7 @@ void RLT_EnableInterrupt(unsigned char channel)
                        TMCSR4_UF = 0;
                        
                        /* Enable Interrupt     */
-                       TMCSR4_INTE = 1;
+                       TMCSR4_INTE = enable;
                        break;
                }       
                case 5:
@@ -209,7 +209,7 @@ void RLT_EnableInterrupt(unsigned char channel)
                        TMCSR5_UF = 0;
                        
                        /* Enable Interrupt     */
-                       TMCSR5_INTE = 1;
+                       TMCSR5_INTE = enable;
                        break;
                }       
                case 6:
@@ -218,7 +218,7 @@ void RLT_EnableInterrupt(unsigned char channel)
                        TMCSR6_UF = 0;
                        
                        /* Enable Interrupt     */
-                       TMCSR6_INTE = 1;
+                       TMCSR6_INTE = enable;
                        break;
                }       
                case 7:
@@ -227,7 +227,7 @@ void RLT_EnableInterrupt(unsigned char channel)
                        TMCSR7_UF = 0;
                        
                        /* Enable Interrupt     */
-                       TMCSR7_INTE = 1;
+                       TMCSR7_INTE = enable;
                        break;
                }
        }
@@ -239,7 +239,7 @@ __interrupt void RLT_Channel0_ISR()
        TMCSR0_UF = 0;
        
        /*      Do what you have to do  */
-       PDR14++;
+       PDR14--; //since the pins are low active
 }
 
 __interrupt void RLT_Channel1_ISR()
diff --git a/RLT.h b/RLT.h
index 3290deddba2e4f2f3e59158bfce1080623a29175..3d8c42380e726b5755f075fd44e808c79f2e7d34 100644 (file)
--- a/RLT.h
+++ b/RLT.h
@@ -30,7 +30,7 @@
 
 void RLT_InitializeTimer(unsigned char channel, unsigned char runmode, unsigned char clockmode, unsigned char triggermode, unsigned char outputmode);
 void RLT_SetReloadValue(unsigned char channel, unsigned short int value);
-void RLT_EnableInterrupt(unsigned char channel);
+void RLT_EnableInterrupt(unsigned char channel, unsigned char enable);
 void RLT_TriggerTimer(unsigned char channel);
 
 __interrupt void RLT_Channel0_ISR();