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 enable the DIGITAL inputs that are multiplexed with the ADC and Comparator pins.

MICROCHIP in their infinite(simal) wisdom has DISABLED the DIGITAL inputs on Power-Up. Leaving everyone to figure out which of the 10 different ways they need to use to turn them on for the chip they're programming at any given time. :(
Sometimes it's ADCON1 and CMCON, other times it's ANSEL and CMCON0, 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 DIGITAL inputs enabled. Whether it's from 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.4 (7/19/2010)
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>Added ANSEL0 and ANSEL1 for the 18F4431 series</td><td align=center>Darrel Taylor</td></tr><tr><td align=center>1.5</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>

Archangel
- 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>

Acetronics2
- 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

Archangel
- 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.

ietcyberwolf
- 20th April 2011, 19:39
Sorry but how can you do ALL_DIGITAL = TRUE on PicBasic PRO?

CMCON=7? is it correct?

Archangel
- 8th May 2011, 05:58
Sorry but how can you do ALL_DIGITAL = TRUE on PicBasic PRO?

CMCON=7? is it correct?
CMCON = 7 is comparators off for many of the pics, not for all, each pic family (read that family members all share a common data sheet) may have very different settings in order to enable digital ports. For you, For Now, go back to the very first post in this thread and get the all digital zip file, unzip it into your pbp directory and include it as Darrel instructed you to do. In his file he has taken the time to read and understand a variety of PIC families and built in enough code to select the appropriate settings. My recommendation to everyone is read those data sheets and struggle with them and ask questions until they begin to make sense. They will begin to make sense. You can find all registers your chip uses in the mpasm suite directory in files with the suffix .inc this chip will be P16F4550.inc . To set ports digital often requires setting several registers like ANSEL, ADCON, CM0CON . . . the data sheet explains what each register does and what each bit controls.

mister_e
- 8th May 2011, 10:28
Sorry but how can you do ALL_DIGITAL = TRUE on PicBasic PRO?

CMCON=7? is it correct?
Read carefully POST #1.

RayL113
- 30th November 2013, 04:24
David, I just wanted to say "Thanks!"
This file has fixed a problem that I have been struggling with for 3 days.
RL

Demon
- 30th November 2013, 05:24
David, I just wanted to say "Thanks!"
This file has fixed a problem that I have been struggling with for 3 days.
RL

You mean Darrel. :)

RayL113
- 1st December 2013, 03:35
"Darrel, I just wanted to say "Thanks!".
Sorry for the mistake.
(Thanks Demon)
RL

Demon
- 4th January 2014, 02:49
Darrel,

1. 18F44K22 - You're missing PortC.

I displayed on a working program and noticed a difference. This is what I have.


ANSELA = %00000000 ' Set ports to digital
ANSELB = %00000000
ANSELC = %00000000
ANSELD = %00000000
ANSELE = %00000000

2. I have a suggestion, maybe rename to DT_AllDigital.PBP, that way they all line up together when browsing PBP folder.


Thanks for awesome utility.

Robert


EDIT: Forgot to say I'm still on PBP 2.60c, if it matters.

Darrel Taylor
- 4th January 2014, 03:23
See this thread ...
http://support.melabs.com/threads/956

Demon
- 4th January 2014, 05:14
Thanks! Updated to v1.5 from that link you provided.

jingjok
- 9th February 2014, 18:01
Does All Digital work in PBP3? I have installed ALLDIGITAL.pbp in the main directory of PBP3, but Micro Code Studio gives me a warning of unable to open INCLUDE file ALL DIGITAL.pbp. I don't know what I'm doing wrong.
Thank you.

Darrel Taylor
- 9th February 2014, 20:56
Yes, it works with PBP3.

Post the actual line of code and errors you are receiving.
Paraphrasing errors doesn't give the information needed to diagnose your problem.

jingjok
- 9th February 2014, 22:25
This is the code, using PBP3, Micro Code Studio Plus, and a 16F648A PIC selected:

INCLUDE "ALL DIGITAL.pbp"
LED var PORTA.0

mainloop:
HIGH LED
PAUSE 500
LOW LED
PAUSE 500
GOTO MAINLOOP
END

I get this message at the bottom:

WARNING: Unable to open INCLUDE file ALL DIGITAL.pbp

I have been unable to determine the reason I am getting this message.
Thank you very much for your help.

Darrel Taylor
- 9th February 2014, 23:03
Remove the space between ALL and DIGITAL.

jingjok
- 10th February 2014, 01:43
Thank you so much! This works perfectly. Last week I had tried to run a Timer 1 program on a 16F886 that had been running perfectly on a 16F876A. The program would not run on the 16F886 until I added:

ANSEL = %00000000
ANSELH = %00000000
ADCON0 = %00000000
ADCON1 = %00000000

which took me FOREVER to find because I am just starting out learning this. ALLDIGITAL.pbp will save me a lot of time.
Thank you again for helping.

marcusk
- 11th February 2018, 16:12
As a relative noob, exactly what I was looking for.
Except...:
I added it to the folder containing pbpx.exe as instructed but on compile Microcode Studio comes back with:
WARNING: unable to open INCLUDE file ALLDIGITAL PBP.
I use PBP3.1

Ioannis
- 12th February 2018, 07:48
You have to include the full path to the file.

Include "C:\BPP31\...."

Ioannis