Vous êtes sur la page 1sur 2

Pic 16f84a pulse counter? - Yahoo!

Answers

http://answers.yahoo.com/question/index?qid=20120501064853AAllKd9

New User? Register

Sign In

Help

Get new Yahoo! Mail apps

Mail

My Y!

Yahoo!

Search
Home > All Categories > Science & Mathematics > Engineering > Resolved Question

Search Web

Pic 16f84a pulse counter?


hi i have connected my pic16f84a to lcs 16*2 like this. ' LCD should be connected as follows: ' LCD PIC ' DB4 PortA.0 ' DB5 PortA.1 ' DB6 PortA.2 ' DB7 PortA.3 ' RS PortA.4 (add 4.7K pullup resistor to 5 volts) ' E PortB.3 ' RW Ground ' Vdd 5 volts ' Vss Ground ' Vo 20K potentiometer (or ground) ' DB0-3 No connect now i want to use it as a pulse counter to measure the freq of inputed pulse. can anyone send me the pbp and asm code.pleeeeease or can you make changes nessesry to this code and send me pbp and asm and hex code for pic16f84a. thanks. Define LCD_DREG PORTA Define LCD_DBIT 0 Define LCD_RSREG PORTB Define LCD_RSBIT 4 Define LCD_EREG PORTB Define LCD_EBIT 5 REM Variables TMR0_POSTCOUNT1 var WORD ' POSTSCALER COUNTERS COUNT_RESULT var WORD ' THE RESULT OF THE COUNT REFRESHED var BIT ' FLAG TO SAY COUNT REFRESHED '-------------------------' ON INTERRUPT GOTO PULSE_COUNT ' DEFINE WHERE TO JUMP TO ON AN INTERRUPT '-------------------------' GOTO INITIALIZE ' JUMP ALL INT CODE '----- INTERRUPT CODE ------------------Disable PULSE_COUNT: TMR0 = TMR0 + 7 ' RELOAD THE TIMER TMR0_POSTCOUNT1 = TMR0_POSTCOUNT1 - 1 IF TMR0_POSTCOUNT1 = 0 THEN TMR0_POSTCOUNT1 = 500 ' 1/4 sec (may need some adjust) T1CON.0 = 0 ' TURN OFF THE TMR1 COUNT_RESULT.lowbyte = TMR1L ' GET THE COUNT COUNT_RESULT.Highbyte = TMR1H ' GET THE COUNT TMR1L = 0 TMR1H = 0 T1CON.0 = 1 REFRESHED = 1 ' SET FLAG TO SAY COUNT READ ENDIF INTCON.2 = 0 ' CLEAR INTTERUPT FLAG Resume enable ' RELOAD THE SYSTEM VARS '------ END OF INTERRUPTS CODE ---------'------ INTIALIzE ALL REGS -------------INITIALIZE: TMR0_POSTCOUNT1 = 500 ' INITIALZE THE POST SCALERS OPTION_REG.0 = 0 ' SET THE PRESCALER TO 1:1 OPTION_REG.1 = 0 OPTION_REG.2 = 0 OPTION_REG.5 = 0 ' TMR0 CLOCK FROM MAIN OSC OPTION_REG.3 = 0 ' IN THIS INSTANCE PRESCALER IS ASSINED TO TMR0 INTCON.2 = 0 ' CLEAR INTERRUPT FLAG T1CON = %00000110 T1CON.0 = 1 ' TURN TIMER 1 ON TMR0 = 7 ' LOAD THE TIMER INTCON.5 = 1 ' ENABLE TMR0 INTERRUPTS REFRESHED = 0 ' DONT MAKE FIRST READ UNTIL MAIN INT HAS OCCURED INTCON.7 = 1 ' START THE WHOLE THING RUNNING COUNT_RESULT = 0 pause 500 lcdout $FE,1

'------ MAIN CODE BELOW HERE ------------LOOP: John IF REFRESHED = 1 THEN

1 of 2

14-May-13 11:26 AM

Pic 16f84a pulse counter? - Yahoo! Answers

http://answers.yahoo.com/question/index?qid=20120501064853AAllKd9

lcdout $fe,1,$fe,2, "Freq = ", dec (COUNT_RESULT * 4) ' Show results in pulses / Sec REFRESHED = 0 ' PREVENT A RE-READ UNTIL NEXT MAIN INTERRUPT ENDIF GOTO LOOP END by srspinho.
1 year ago ( 2012-05-01 13:48:54 +0000 ) Report Abuse

Additional Details (make the links visible) Thx for your concern...
1 year ago

Best Answer - Chosen by Voters


The first link is the .php code. The second link is the .asm code. The third link is the hex code, in INTEL format. Let me know if you need a different format! I tested the code pretty thouroughly on the pic16f84a, and also on the Atmega 256. It does a perfect job of frequency measurement, as far as I can tell. Let me know if you would like a diiferent user interface! Note: The links may not show up if you have any illegal software on your computer. If this is the case, simply replace it with legal software. Edit: The links show up just fine on my machine! Have you checked your WinZip software? That is a common problem that people seem to have.
Edited 1 year ago ( 2012-05-02 21:18:57 +0000 ) Report Abuse

100% 1 Vote SMDave

Other Answers (0)


No other answers.

2 of 2

14-May-13 11:26 AM