Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to Using MPLAB and Hi-tide Group #9 JoseAlex MikeRoberto Goto and print the file

Similar presentations


Presentation on theme: "Introduction to Using MPLAB and Hi-tide Group #9 JoseAlex MikeRoberto Goto and print the file"— Presentation transcript:

1 Introduction to Using MPLAB and Hi-tide Group #9 JoseAlex MikeRoberto Goto http://www.alexhan.net/senior.html and print the file http://www.alexhan.net/senior.html

2 Purpose of Programs  Cgywin is to emulate Linux to run the other programs  Picc lite and Hi-tide are the environment to write your code for programming the microcontroller and converts to Hex  MPLAB is software that allows the codes to be transferred to the microcontroller

3 Program Code  Motor Control  IR Sensor  Key Debouncer

4 LED On #include "init.h"// included by C-Wiz #include #include void main(void) { init();// Function call inserted by C-Wiz while (1){ RA0=1; //TODO Auto-generated main function }}

5 LED flashing 5 sec int i,k; void main(void) { init();// Function call inserted by C-Wiz while (1){ k=0; while (k<1000){ i=0;k++; while (i<1500){ i++;}}RA0=RA0^1;}}

6 LED Flashing w / Interrupts  #include "init.h"// included by C-Wiz  #include  #include  int k;  double maxval = 1000;  int f;  int i;  const int Twentyms = 1150; // Declare a Constant for 20 ms Delay  void  main(void)  {  k=0;  init();// Function call inserted by C-Wiz  while(1 == 1) // Loop Forever  {  i = 0; // Wait 20 ms for Button Up  while (i < Twentyms)  {  if (0 == RE2) // Button Down/Start over  {  i = 0;  }  else // Button Up/Increment Count  {  i = i + 1;  } // fi  } // elihw  NOP();  i = 0; // Wait 20 ms for Button Down  while (i < Twentyms)  if (1 == RE2) // Button Up/Start over  i = 0;  else // Button Down/Increment Count  i = i + 1;  RB1 = RB1 ^ 1; // Toggle RA5 to Turn ON/OFF LED   } // elihw  } // End cDebounce

7 Conflict With Loop  #include "init.h"// included by C-Wiz  #include  #include  int i,k,j;  const int Twentyms = 1150; // Declare a Constant for 20 ms Delay  void  main(void)  {  init();// Function call inserted by C-Wiz  while (1){  k=0;  while (k<1000){  i=0;  k++;  while (i<1500){  i++;}  }  RA0=RA0^1;  j = 0; // Wait 20 ms for Button Up  while (j < Twentyms)  {  if (0 == RE2) // Button Down/Start over  {  j = 0;  }  else // Button Up/Increment Count  {  j = j + 1;  }  NOP();  j = 0; // Wait 20 ms for Button Down  while (j < Twentyms)  if (1 == RE2) // Button Up/Start over  j = 0;  else // Button Down/Increment Count  j = j + 1;  RB1 = RB1 ^ 1;  }

8 Key De-bouncer  //trial debouncer  #include "init.h"// included by C-Wiz  #include  #include  int i;  const int Twentyms = 1150; // Declare a Constant for 20 ms Delay  main()  {  init();// Function call inserted by C-Wiz  while(1 == 1) // Loop Forever  {  i = 0; // Wait 20 ms for Button Up  while (i < Twentyms)  {  if (0 == RE2) // Button Down/Start over  {  i = 0;  }  else // Button Up/Increment Count  {  i = i + 1;  } // fi  } // elihw

9 Key De-bouncer Cont.  NOP();  i = 0; // Wait 20 ms for Button Down  while (i < Twentyms)  if (1 == RE2) // Button Up/Start over  i = 0;  else // Button Down/Increment Count  i = i + 1;  RA0 = RA0 ^ 1; // Toggle RA5 to Turn ON/OFF LED  // RB4 = RB4 ^ 1; // Toggle RA5 to Turn ON/OFF LED  RB1 = RB1 ^ 1; // Toggle RA5 to Turn ON/OFF LED  } // elihw  } // End cDebounce

10 Motor Control main(void) { init();// Function call inserted by C-Wiz while (1){ RA0=RA0^1;i=0; while(i<10) {i++;k=0; while(k<3000) {k++;}} //CCPR1L= 0b01111111; A=A+1; CCPR2L= A; if(CCPR2L==0XFF) CCPR1L=~CCPR1L;

11 IR Sensor #include "init.h"// included by C-Wiz #include #include void main(void) { init();// Function call inserted by C-Wiz while (1){ if(RB2==1) RA0=0;elseRA0=1; //TODO Auto-generated main function }}

12 The End Thanks Ya’ll Email or get in touch with us for more information or questions.


Download ppt "Introduction to Using MPLAB and Hi-tide Group #9 JoseAlex MikeRoberto Goto and print the file"

Similar presentations


Ads by Google