Skip to content

Commit

Permalink
Lab2 finished. and we fixed the bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
Einholz-Gao committed Nov 17, 2022
1 parent 915380d commit 6694184
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 19 deletions.
2 changes: 1 addition & 1 deletion Lab1/nbproject/Makefile-genesis.properties
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<defaultConf>0</defaultConf>
<confs>
<conf name="default" type="2">
<platformToolSN>:=MPLABComm-USB-Microchip:=&lt;vid>04D8:=&lt;pid>9009:=&lt;rev>0100:=&lt;man>Microchip Technology, Inc. (www.microchip.com):=&lt;prod>MPLAB ICD3 tm (www.microchip.com):=&lt;sn>BUR183272645:=&lt;drv>x:=&lt;xpt>b:=end</platformToolSN>
<platformToolSN>:=MPLABComm-USB-Microchip:=&lt;vid>04D8:=&lt;pid>9009:=&lt;rev>0100:=&lt;man>Microchip Technology, Inc. (www.microchip.com):=&lt;prod>MPLAB ICD3 tm (www.microchip.com):=&lt;sn>BUR183272642:=&lt;drv>x:=&lt;xpt>b:=end</platformToolSN>
<languageToolchainDir>/opt/microchip/xc16/v1.36/bin</languageToolchainDir>
<mdbdebugger version="1">
<placeholder1>place holder 1</placeholder1>
Expand Down
31 changes: 15 additions & 16 deletions Lab2/Lab02_Interrupts_Timers.X/src/lab02.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 ??
Expand Down

0 comments on commit 6694184

Please sign in to comment.