What Andy proposed (1 LED) and Richard (RMW).
Also, put AllDigital back in and doublecheck the code generated.
Robert
What Andy proposed (1 LED) and Richard (RMW).
Also, put AllDigital back in and doublecheck the code generated.
Robert
I would like to thank all those who helped looking over the code. The commands I chose were those that I found on this forum, but did not work. So, with that said, I would like to post what I did that got my program working again.
First off, ADCON1 = whatever. Don't use it. It'll just screw things up. Second, I did not have any success with Darrel's AllDigital include. Not saying it doesn't work, it just didn't work for me.
What did get it working again was using ANSELA = 0, ANSELB = 0 and ANSELC = 0. I used ANSEL for setting each register to digital, TRIS for selecting input/output and then PORT for setting the outputs to high or low. This was the first step in setting up my code. Then, you have to change your output variables from port to lat. For instance, my LED variable of LED1 var porta.1 needed to be changed to LED1 var lata.1. You can Google it like it was suggested above, but I found I understood it better when viewing a youtube video of the explanation along with circuit and oscilloscope examples. Just remember, only the outputs get changed from port to lat. Leave the inputs as portx, but change the outputs to latx.
Thanks again to all those that helped and I hope my explanation will help those in the future.
Tony
ANSELx = ANALOG SELECT or inversely Digital Select . . .
ADCON0 is where you choose which Analog Channel to use
ADCON1 is where you CHOOSE what your voltage references are & Trigger Select
ANSELA configures portA Analog or Digital
ANSELB configures portB Analog or Digital
ANSELC " " " " " portC Analog or Digital
ANSELD " " " " " portD Analog or Digital
ANSELE " " " " " portE Analog or Digital
All about COMPARATORS Below from Data Sheet
Comparators are really good at causing you to tear out your hair while trying to get the PIC to do digital too.Code:TABLE 18-2: REGISTERS ASSOCIATED WITH COMPARATOR MODULE Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 Register on Page ANSELA — — ANSA5 — ANSA3 ANSA2 ANSA1 ANSA0 154 ANSELB — — ANSB5 ANSB4 ANSB3 ANSB2 ANSB1 ANSB0 155 CM2CON1 MC1OUT MC2OUT C1RSEL C2RSEL C1HYS C2HYS C1SYNC C2SYNC 318 CM1CON0 C1ON C1OUT C1OE C1POL C1SP C1R C1CH<1:0> 317 CM2CON0 C2ON C2OUT C2OE C2POL C2SP C2R C2CH<1:0> 317 VREFCON1 DACEN DACLPS DACOE — DACPSS<1:0> — DACNSS 347 VREFCON2 — — — DACR<4:0> 348 VREFCON0 FVREN FVRST FVRS<1:0> — — — — 344 INTCON GIE/GIEH PEIE/GIEL TMR0IE INT0IE RBIE TMR0IF INT0IF RBIF 116 IPR2 OSCFIP C1IP C2IP EEIP BCL1IP HLVDIP TMR3IP CCP2IP 129 PIE2 OSCFIE C1IE C2IE EEIE BCL1IE HLVDIE TMR3IE CCP2IE 125 PIR2 OSCFIF C1IF C2IF EEIF BCL1IF HLVDIF TMR3IF CCP2IF 120 PMD2 — — — — CTMUMD CMP2MD CMP1MD ADCMD 57 TRISA TRISA7 TRISA6 TRISA5 TRISA4 TRISA3 TRISA2 TRISA1 TRISA0 156 TRISB TRISB7 TRISB6 TRISB5 TRISB4 TRISB3 TRISB2 TRISB1 TRISB0 156
Sorry this post comes too late to help you, I bet you won't forget though. Keep up the good work Tony.
JS
Last edited by Archangel; - 25th November 2014 at 07:59.
If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
.
Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
.
There simply is no "Happy Spam" If you do it you will disappear from this forum.
just for the record what version of alldigital.pbp did you try ? there are a number of versions
is not right ,it just does not do what you erroneously thought it did as archangel saysFirst off, ADCON1 = whatever. Don't use it. It'll just screw things up.and needs to set appropriately " rtfm "ADCON1 is where you CHOOSE what your voltage references are & Trigger Select
Richard,
Problem is; None of this is in the manual, it's in the data sheet, and it takes some of us a while before we understand how to read it, and when we get frustrated, it's just harder. That's why I explained it the way I did, because Acronyms are always obvious . . . to the person who makes them. The rest of us, maybe not so much.
If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
.
Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
.
There simply is no "Happy Spam" If you do it you will disappear from this forum.
as tony discovered the wrong info in a thread can lead you astray , I don't think perpetuating error helps anyone but the right info is priceless
Hi,
Here's my view on this....
This sort of info can't be in the manual because then the manual would be the size of all the 8bit PIC datasheets combined.
[rant]
It's up to the user to set the registers correctly for the application at hand, HOW to set them IS described in the manual, WHAT to set the TO is described in the datasheet for the particular PIC. Yes, it does take some time to learn what to look for in a datasheet but you're going to have to learn it.
Just because you find a piece of code where you see some_register = some_value ' Enable this, do that doesn't mean it'll work for you and your PIC. Take CMCOM for example, it's not uncommon that someone finds a piece of code, on this forum, where it says CMCON=7 ' Turn off comparators, uses that on a completely different PIC than the one for which the code was written and ultimately ends up in trouble. All because the comment said Turn off comparators - which it of course does on the PIC for which it was written. On some chips the registers are named differently, on others you need CMCON=15, on others you don't need to anything.The commands I chose were those that I found on this forum, but did not work.
Where exactly did you find the reference to ADCON1=15?
Finally, just because you find pieces of code an a forum doesn't mean it's correct, working, debugged code ready to go. Most of the code posted here contains errors and problems - which is usually the reason for it being posted in the first place even though you're sometimes asked to troubleshoot code without even seeing it.
[/rant]
/Henrik.
Bookmarks