![]() | ![]() | ![]() |
| |||||||
| Electronic Projects Design/Ideas/Reviews Are you building an electronic project or want to? Maybe you need some assistance? Come and submit your electronic questions here and let our experienced members find a solution. |
![]() |
| | Tools |
| | #1 |
|
hi all im having problem with writing assembly language that will implement a stopwatch!!! i have to design it so that it has a count to the base 7 and has max count of 66! i also have to implement a delay of 1.38s for each count(i.e time taken for it to go from 1 value to the next) the clock is 20MHz and each instruction takes 200ns! any help will be appreciated | |
| |
| | #2 |
|
Why do you "have" to design it that way? Posting your code would help. | |
| |
| | #3 |
|
Here's a code snippet that may help. It sets up timer 1 so that it overflows every 10mS. Code: movlw B'00000001' movwf T1CON; enable timer 1 movlw low(.50000) movwf CCPR1L movlw high(.50000) movwf CCPR1H movlw B'00001011'; enable special event trigger on CCP1 movwf CCP1CON; Code: Wait btfss PIR1,CCP1IF goto Wait bcf PIR1,CCP1IF; reset special event trigger bit incf ........etc Mike. Mike. | |
| |
| | #4 |
|
hey i have to design it that way because its part of the specification for my project!!! that snippet you sent is that for the pic16f877a(20MHz clock,200ns intruction cycle) | |
| |
| | #5 | |
| Quote:
| ||
| |
| | #6 |
|
alrite i think i have got the counter to count to the base7 but its the delay of 1.38s im having problem with | |
| |
| | #7 | |
| Quote:
| ||
| |
| | #8 |
|
Just use the code I posted earlier. Test the bit and increment a counter, once it gets to 138 your 1.38s is up. Mike. | |
| |
| | #9 |
|
Mike (Pommie) actually provided a workable 10 msec timer solution. The OP really just needs to add a counter that counts 138 of those timer 'ticks' before incrementing his digit counters. Gosh, how hard could it be? Code: ;
;
Wait btfss PIR1,CCP1IF ; 10 msec timeout?
goto Wait ; no, branch and wait, else
bcf PIR1,CCP1IF ; clear Timer 1 interrupt flag
decfsz Timer,F ; has 1380 usecs elapsed?
goto Wait ; no, branch, else
movlw d'138' ; reset 1380 usec Timer var'
movwf Timer ;
;
; increment digit counters here then jump back to the Wait sub'
;
Last edited by Mike, K8LH; 23rd November 2007 at 06:01 PM. | |
| |
| | #10 |
|
Mike, Your absolutely spot on except for the bit that is set. It is PIR1,CCP1IF that gets set rather than the timer1 interrupt flg. Mike. | |
| |
| | #11 |
|
Oops! Please pardon me. I corrected my previous post.
| |
| |
| | #12 | |
|
hey all what is PIR1,CCP1IF? are these variables set at the start of the prog? is the very early ppost u put up is that the beginning of the 10msec delay? thanks again ![]() Quote:
| ||
| |
| | #13 |
|
hi i was on the PICList website and looking at the delay code generator ... it uses an instruction similar to this goto $+1? what does the $ sign mean? | |
| |
| | #14 | |
| Quote:
| ||
| |
| | #15 | |
| Quote:
Mike, K8LH posted example code to show how you would use this bit. It sounds like you need to familiarise yourself with the pic opcodes. Having a read of the sticky and working your way through some of the tutorials would be a good way to learn. Mike. | ||
| |
|
| Tags |
| building, pica, stopwatch |
| Thread Tools | |
| Display Modes | |
| |
Similar | ||||
| Title | Starter | Forum | Replies | Latest |
| Robot Building for Beginners | Souper man | Electronic Books | 15 | 17th April 2009 08:07 PM |
| wind speed meter with direction using PIC16f877A, rotary encoder and LCD 16x2 | mokh | Electronic Projects Design/Ideas/Reviews | 14 | 29th October 2008 08:00 AM |
| mclr pin problem for pic16f877a | neelam29 | Micro Controllers | 6 | 7th February 2007 02:04 PM |
| What is the best C Compiler for PIC16F877A? | dimastar85 | Micro Controllers | 14 | 23rd December 2006 11:21 PM |
| Building a signal mixer (for music primary) | thec | Electronic Projects Design/Ideas/Reviews | 4 | 3rd October 2002 06:07 PM |