![]() | ![]() | ![]() |
| | |||||||
| Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc. |
| | Thread Tools | Display Modes |
| | (permalink) |
| New Member | I'm trying to set and use the comparators in the PIC16F628. I have been reading the PIC16F628 data sheet for quit a while, and I followed almost exactly all their guidelines but the code doesn't work. Things aren't as straightforward as one expects. I have the feeling one has to figure out and find implicit information though barely implied! Unfortunatelly Nigel Goodwin's tutorials all turn off the comparators. Is anybody experienced with them who can help me get them to function? Here are two versions of the code, both paralysed! Please have a look at them and try to help me generously. I'd appreciate that. |
| | |
| | (permalink) |
| Experienced Member | I just opened the first attachment and can't see how your code gets executed, you have org 0 and then nothing. At reset your code is going to execute your ISR and then return to some unidentified location. Try adding, Code: ORG 0x00 goto Start ORG 0x04 movwf W_COPY ;save W register swapf STATUS, W movwf S_COPY ;save STATUS register MOVLW b'11111111' MOVWF PORTB CALL Delay CLRF PORTB CALL Delay SWAPF S_COPY, W MOVWF STATUS ; STATUS BACK SWAPF W_COPY, F ; SWAPF W_COPY, W ; W BACK RETFIE Start ;comparator initialisation CLRF FLAG_REG ;initialise flag register CLRF PORTA ;initialise portA MOVF CMCON,W ;load comparator bits Mike. |
| | |
| | (permalink) |
| New Member | Thanks for the suggestions. I have tried this before and I removed the goto start on purpose because I get some flickering leds on portb. |
| | |
| | (permalink) | |
| Super Moderator | Quote:
| |
| | |
| | (permalink) |
| New Member | Hello Mr. Goodwin, Firstly I do appreciate your work and the tutorials. Secondly and as for my post, do you mean everything is OK? Is it working? Because I push the buttons on RA0 and RA1 (from high to low CompTest2) I get no response on portb. Last edited by Ramos; 12th May 2008 at 05:43 PM. |
| | |
| | (permalink) |
| Experienced Member | Ramos, What do you expect to happen after you set TRISB? You just fall into your delay subroutine, which eventually does a return. There was never any call. Mike |
| | |
| | (permalink) | |
| Super Moderator | Quote:
| |
| | |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
| |
| | ||||
| Thread | Thread Starter | Forum | Replies | Latest |
| Question: Difference between comparators and op amps? | speakerguy79 | General Electronics Chat | 12 | 2nd January 2008 07:35 AM |
| eeprom internal pic16f628 | neelam29 | Micro Controllers | 5 | 17th February 2006 08:58 AM |
| PIC16F628 to PIC16F84 | kasamiko | Micro Controllers | 2 | 5th May 2005 04:26 PM |
| Pic16F628 using too much power while asleep | Exo | Micro Controllers | 1 | 22nd April 2004 06:17 PM |