Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Configure the PICs control register so that the Timer0 module will count low-to-high logic transitions (PGTs) on its external clock pin and display them (the

Configure the PICs control register so that the Timer0 module will count low-to-high logic transitions (PGTs) on its external clock pin and display them (the total number of switch presses) on an LCD. Connect a properly wired push-button switch to this clock pin, such that when pressed a PGT will be generated. In effect, the counter will count the number of switch presses. If the switch is simply connected in this way the count will probably be erroneous because of contact bounce or noise. Therefore, you should use a debounce circuit with your switch. The switch should work properly, regardless of how quickly or slowly it is pressed. The LCD must always display the proper count value and must update immediately with every switch press. You may assume that the switch will not be pressed more than 50 times.

***** I only need the int main of the code and the numbers have to be converted using ascii.*****

THIS IS WHAT I HAVE SO FAR....

int main (int argc, char** argv) { OSCCON = 0x72; ANSELA = 0; //PORTA all digital ANSELB = 0; // PORTB all digital ANSELC = 0; // PORTC all digital //TRISA=0x10;//RA4 set to input //TRISB=0x07; //RB0-RB2 inputs //TRISC=0x00;// outputs TMR0=0; TRISAbits.RA4=1;// RA4 IS T0CKI pin T0CON=0x68; //0110 1000: off, 8-bit, T0CKI pin, rising edge, no prescaler TMR0L=255;// timer0 initialized to 255 INTCONbits.TMR0IE=1; //locally enable the Timer0 interrupt INTCONbits.TMR0IF=0; // Clear the Timer0 interrupt flag INTCONbits.PEIE=1; // Globally enable all the peripheral interrupt INTCONbits.GIE=1; // Globally enable all the interrupts T0CONbits.TMR0ON=1;//turn on timer0 intLCD(); while(1) { unsigned char c[1]=0; unsigned char i=0, j=0; unsigned char count=0; TMR0=0; if(TRISAbits.RA4==1) { i = 0; c[1] = 0; } if (TMR0 > 0 && TMR0 < 50) { count++ +'0'; } if (i == 5 && j == 0 ) { j = 0; i = 0; } RS=0; PORTC=0x01; clockE(); PORTC=0x80; clockE(); RS=1; PORTC=(i + '0'); clockE(); PORTC=('0'+(count % 10)); clockE(); PORTC=c[1]+'0'; clockE(); // writes to the LCD }//while return (EXIT_SUCCESS); }// main

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

What purpose is served by the check-the-box Regulations?

Answered: 1 week ago