diff --git a/Lab1/nbproject/Makefile-genesis.properties b/Lab1/nbproject/Makefile-genesis.properties
index b6a9ea1..0890a79 100644
--- a/Lab1/nbproject/Makefile-genesis.properties
+++ b/Lab1/nbproject/Makefile-genesis.properties
@@ -1,5 +1,5 @@
#
-#Thu Nov 10 14:30:48 CET 2022
+#Thu Nov 17 13:07:04 CET 2022
configurations-xml=0aa82a72042584f41c7603a9aac86f6f
com-microchip-mplab-nbide-embedded-makeproject-MakeProject.md5=dc9c2ac0d70cabe9d7d8885d9d2d4ebe
host.platform=linux
diff --git a/Lab2/Lab02_Interrupts_Timers.X/nbproject/Makefile-genesis.properties b/Lab2/Lab02_Interrupts_Timers.X/nbproject/Makefile-genesis.properties
index 4085433..3c2c019 100644
--- a/Lab2/Lab02_Interrupts_Timers.X/nbproject/Makefile-genesis.properties
+++ b/Lab2/Lab02_Interrupts_Timers.X/nbproject/Makefile-genesis.properties
@@ -1,5 +1,5 @@
#
-#Wed Nov 16 14:39:09 CET 2022
+#Thu Nov 17 13:08:54 CET 2022
default.com-microchip-mplab-nbide-toolchainXC16-XC16LanguageToolchain.md5=0a1b983063e12bcca5e35309a0dfef92
default.languagetoolchain.dir=/opt/microchip/xc16/v1.36/bin
configurations-xml=f068e0a88a9ed45f24a63b1e766016c9
diff --git a/Lab2/Lab02_Interrupts_Timers.X/nbproject/private/configurations.xml b/Lab2/Lab02_Interrupts_Timers.X/nbproject/private/configurations.xml
index cf4eb7c..e6f31b3 100644
--- a/Lab2/Lab02_Interrupts_Timers.X/nbproject/private/configurations.xml
+++ b/Lab2/Lab02_Interrupts_Timers.X/nbproject/private/configurations.xml
@@ -4,7 +4,7 @@
0
- :=MPLABComm-USB-Microchip:=<vid>04D8:=<pid>9009:=<rev>0100:=<man>Microchip Technology, Inc. (www.microchip.com):=<prod>MPLAB ICD3 tm (www.microchip.com):=<sn>BUR183272645:=<drv>x:=<xpt>b:=end
+ :=MPLABComm-USB-Microchip:=<vid>04D8:=<pid>9009:=<rev>0100:=<man>Microchip Technology, Inc. (www.microchip.com):=<prod>MPLAB ICD3 tm (www.microchip.com):=<sn>BUR183272642:=<drv>x:=<xpt>b:=end
/opt/microchip/xc16/v1.36/bin
place holder 1
diff --git a/Lab2/Lab02_Interrupts_Timers.X/src/lab02.c b/Lab2/Lab02_Interrupts_Timers.X/src/lab02.c
index 0da3b8e..00fb15e 100644
--- a/Lab2/Lab02_Interrupts_Timers.X/src/lab02.c
+++ b/Lab2/Lab02_Interrupts_Timers.X/src/lab02.c
@@ -43,7 +43,7 @@ void initialize_timer()
// Load Timer Periods
PR1 = 128;// 1 second starting from 0
PR2 = 100;// 2 milliseconds
- PR3 = 100000000000000;//Problem!!!!!!!!!!!!!!!!!!!!!!
+ PR3 = 65535;//max value for PR3 is 16bit
// Reset Timer Values
TMR1 = 0x00;
TMR2 = 0x00;
@@ -75,25 +75,24 @@ void timer_loop()
TMR3 = 0x00;
while(TRUE)
{
- int T1 = T1_counter/60;
- lcd_locate(0, 2);
- lcd_printf("%2d:%2d.%3d",T1,T1_counter%60,T2_counter*2%1000);
- float time = TMR3/12800;
-// if (T3_counter == 2000){
-// TOGGLELED(LED3_PORT);
+ T3_counter++;
+
+ //we put the lcd functions inside if() to speed up the loop.
+ if (T3_counter == 2000){
+ lcd_locate(0, 2);
+ lcd_printf("%2d:%2d.%3d",T1_counter/60,T1_counter%60,T2_counter*2%1000);
+ TOGGLELED(LED3_PORT);
+ float time = (float)TMR3/12800;//to calculate it, check the manual page 13.
lcd_locate(0, 3);
- lcd_printf("TMR3=%d",TMR3);
+ lcd_printf("TMR3=%u",TMR3);//use unsigned int here.
lcd_locate(0, 4);
- lcd_printf("time: %f",time);
-// TMR3=0x00;
-// T3_counter=0;}
-// T3_counter++;
+ lcd_printf("time: %6.4fms" ,time);//6means max number of characters is 6; 4means the number of decimals
+ TMR3=0x00;
+ T3_counter=0;}
+
}
}
-//Problem:
-//1.TMR3 works not good
-//2.loop works slowly.
-//3.PR3 highest value???
+
void __attribute__((__interrupt__, __shadow__, __auto_psv__)) _T1Interrupt(void)
{ // invoked every ??