PDA

View Full Version : All Digital


Darrel Taylor
- 2nd May 2009, 08:43
ALLDIGITAL.pbp

If you want to use all the pins on your PIC as general Input/Output, you must first disable any ANALOG functions that are multiplexed with those pins.

MICROCHIP in their infinite(simal) wisdom has ENABLED many ANALOG functions on Power-Up. Leaving everyone to figure out which of the 10 different ways they need to use to turn them off for the chip they're programming at any given time. :(
Sometimes it's ADCON1 and CMCON, other times it's ANSEL and COMCON0, and still others it might take ANSELA ANSELB ANSELC and ANSELD.

This file is an attempt to rectify that situation.
I've tested it on all the common chips we use with PBP, and it workes extremely well.
<hr>

Simply INCLUDE the file, and all PINs will have any ANALOG functions disabled. Whether it's the A/D converter or the Comparator(s).
A single line will remove that big thorn from your ...

INCLUDE "ALLDIGITAL.pbp"

If you are using MPASM for the assembler, add the following line to your program and the registers that need to be set for the CPU you are compiling for will be shown in the "Results" window of MCS.DEFINE SHOWDIGITAL 1

For example, with a 16F877A it would show ... ... MESSAGE:(ADCON1 = 7)
... MESSAGE:(CMCON = 7)
At that point, you can just add those lines to your program and delete the INCLUDE line.
If it shows a 0x7F type number, change it to $7F.

Or for better compatibility, you can leave the INCLUDE in your program, and it will work with whatever chip you are compiling for.

Here's a simple example for blinking an LED on PORTA.0, without worrying about the analog registers.INCLUDE "ALLDIGITAL.pbp"

Main:
TOGGLE PORTA.0
PAUSE 500
GOTO Main<hr>
Current Version = 1.3
Version History:<table border=1 cellspacing=1 cellpadding=3><tr><td>Version</td><td>Reason</td><td align=center>Credit</td></tr><tr><td align=center>1.0</td><td>Initial release</td><td align=center>Darrel Taylor</td></tr><tr><td align=center>1.1</td><td>Added Shared address SFR support for 18F87J50 family</td><td align=center>mister_e/scalerobotics</td></tr><tr><td align=center>1.2</td><td>Removed MPASM specific opcode (variable), for PM.exe</td><td align=center>Tobias</td></tr><tr><td align=center>1.3</td><td>Added ANSELA,B,D and E for the 16F72x series</td><td align=center>Darrel Taylor</td></tr><tr><td align=center>1.4</td><td align=center>unknown</td><td align=center>This could be you!</td></tr></table>
The attached .zip has only one file, ALLDIGITAL.pbp extract it to your PBP folder (the one with PBPW.exe).
<br>

Joe S.
- 2nd May 2009, 09:02
Beau Geste ! Creative people + Frustration = Interesting solution. You keep throwing these out there, my six year old grandson is going to be writing usable code. In fact this might be the one.

sayzer
- 2nd May 2009, 10:26
Helpful indeed.

May be, with the next version, we can select which CH(s) we want as analog. With some limitations of course.

@SELECT_CH CH0=1 'Select CH0 as analog.


Thanks a lot DT.


_____________________________

Darrel Taylor
- 3rd May 2009, 00:53
May be, with the next version, we can select which CH(s) we want as analog.
But then it wouldn't be ALL DIGITAL. :D

That's a little more datasheet searching than I'm up for. :eek:
Would be nice though.
<br>

Acetronics
- 3rd May 2009, 10:58
Hi, Darrel

Play it Grand size !!! ...

Why not raise us a full PBP Wizard like some "C" IDEs or the MPLAB VDI are Showing ??? Sure it would bring some $$$++ home ...

Ah, human lazyness ... how much will it cost us ???

Regards

Alain

mister_e
- 3rd May 2009, 22:17
Nice one Darrel.

Darrel Taylor
- 4th May 2009, 02:19
Creative people + Frustration = Interesting solution.

Creative people + Frustration<sup>3</sup> = Interesting solution.

There must be an end to the "I can't blink an LED" threads. :eek:


INCLUDE "ALLDIGITAL.pbp"

Main:
TOGGLE PORTA.0
PAUSE 500
GOTO Main

Ohhhhh, but then there's the CONFIG's. :(
Arrrrghhh!

Thanks Joe!
And Steve.
<br>

Ioannis
- 4th May 2009, 12:11
This an all the others (DT-Instant Interrupts, PWM, Bar Graph, etc) exceptional pieces of code, I think should be included in the next PBP release.

Have you thought of talking to Melabs? It would make their product classes higher.

Ioannis

Darrel Taylor
- 5th May 2009, 01:56
No way, they can't have them. :eek:

If they just add all my stuff to PBP, it would invalidate the programs I've spent 1000's of hours developing and supporting over the years.
They'd have everything, and I'd have nothing but a bunch of useless old threads.

Of course, if there were Large sums of money involved, I might be persuaded. :)
<br>

Ioannis
- 5th May 2009, 08:58
Of course, if there were Large sums of money involved, I might be persuaded. :)
<br>

I never meant for free of course! And I am sure all here may be willing to pay a little extra for better product.

None of the competitive products do not have the Interrupts or Bar Graph quality you did. You gave us a really special present and is really appreciated :-)

Anyway...

Ioannis

Joe S.
- 5th May 2009, 09:34
Now what would you DO with all that dirty filthy money?:eek:

Darrel Taylor
- 6th May 2009, 10:28
Now what would you DO with all that dirty filthy money?:eek:
I would use it to pay the bills,
so I had nothing else to worry about besides creating the next FREE include file. :)
<br>

mister_e
- 6th May 2009, 16:49
How about a Paypal donation button on your website?

mister_e
- 7th May 2009, 05:43
From
http://www.picbasic.co.uk/forum/showthread.php?t=11128

ALLDIGITAL will need some adjustments for 18F87J50 family and probably some others.

On this family, ANCON1, ANCON0 are alternate SFR to ADCON0, ADCON1. They share the same address, so you need to set/clear WDTCON.ADSHR to switch between SFRs before writing on... dear Microchip ;)

http://ww1.microchip.com/downloads/en/DeviceDoc/39775b.pdf
Section 5.3.5.1, pdf page 82, Shared SFRs & WDTCON

Darrel Taylor
- 7th May 2009, 08:52
I just knew there would be some Oddball chips somewhere.
And shared SFR addresses, with the select bit in the Watchdog Timer control, definitely qualifies as Oddball.

I've updated the program, and replaced the original .zip in post#1.
http://www.picbasic.co.uk/forum/attachment.php?attachmentid=3380

Thanks mister_e. http://www.picbasic.co.uk/forum/images/icons/icon14.gif

mister_e
- 8th May 2009, 02:55
Well... thanks to scalerobotics for having bring that PIC in here ;)

Definitely, i'll never understand Microchip... that's a real oddball indeed.

Can't really understand the reason why they used that sharing address method... and with WatchDog register... well... yes and no... but certainely not 100%.

Question is... do they have an answer for that themself? :D

Universal answer??? Because!

Darrel Taylor
- 10th May 2009, 00:30
Thanks to Tobias, another error has been found, and repaired.
http://www.picbasic.co.uk/forum/showthread.php?p=73978#post73978

The file has been updated to version 1.2
http://www.picbasic.co.uk/forum/attachment.php?attachmentid=3380

I appreciate the efforts of everyone helping to make this the answer to the Analog problem.

Thank you,

Balachandar
- 21st June 2009, 14:27
Thanks a lot, Darrel.

This is another great contribution from your side that increases the value of PBP and also reduces the possibility of the code not working as expected.

Bala

Darrel Taylor
- 12th July 2009, 04:43
While attempting to use my first 16F723, I found that they have ANSELA and ANSELB instead of ANSEL and ANSELH.
Only the 16F72x series has them.

ALLDIGITAL.pbp has been updated to version 1.3
http://www.picbasic.co.uk/forum/attachment.php?attachmentid=3380
See post#1 for instructions and version history.

jellis00
- 29th November 2009, 00:57
.

ALLDIGITAL.pbp has been updated to version 1.3
http://www.picbasic.co.uk/forum/attachment.php?attachmentid=3380
See post#1 for instructions and version history.

Darrell,
I have been having some problems in my coding of an application for the 18F4550 and suspected I was missing something in setting the ops to pure digital. Attempted to use your ALLDIGITAL.pbp as an INCLUDE and it appeared normal, but at time of compile/assembly I did NOT see any listing in the Assembly window when I decommented the DEFINE statement. That made me wonder if ALLDIGITAL.pbp was even compatible with the 18F4550. Is it, or if not can you advise me how to modify it to include??

mackrackit
- 29th November 2009, 04:22
ADCON1 = 15
Sets all to digital.

jellis00
- 29th November 2009, 05:09
ADCON1 = 15
Sets all to digital.
Thanks, Dave. Would like to know how to make this modification in DT's ALLDIGITAL.pbp for use as an INCLUDE, but at least your info got me going with using the ADCON1 statement in the code. Appreciate your input.

Darrel Taylor
- 29th November 2009, 05:16
... Would like to know how to make this modification in DT's ALLDIGITAL.pbp for use as an INCLUDE

??????

It is an Include, and no modifications are required.
Or maybe there's more to the question.
<br>

jellis00
- 29th November 2009, 20:54
??????

It is an Include, and no modifications are required.
Or maybe there's more to the question.
<br>

Ignore my previous, Darrell. What I was saying is I wanted to modify the code in ALLDIGITAL.pbp so it would work with the 18F4550. I didn't think it was working because I wasn't getting any messages in the Assembly window when I uncommented the DEFINE statement that lists the configs made by ALLDIGITAL.pbp. Turns out I had mispelled DIGITAL in the statement as the reason it wasn't listing the messages. Once I fixed that I discovered that ALLDIGITAL.pbp version 1.3 does already work with the 18F4550. Sorry for the confusion.