PDA

View Full Version : pic Basic Pro 2.50a & debug statement



Phil Moore
- 9th March 2008, 06:51
Code below for 16F737 compiles & runs just fine under PBP 2.46. Compile under 2.50a and everything runs OK *EXCEPT* DEBUG (nothing changes on debug pin).

Running MicroCode Studio v3.0.0.5 & WinPIC v??? (compiled Jun 3 2007). Using MPLAB 7.60.00.00 and MPASM (not PM).


Am I going nuts or is something broken?

' Code:
' System Constants
OSCCON = $F0 ' Tell the PIC
ADCON1 = 7
CMCON = 7

' Defines
DEFINE OSC 8 ' Tell PicBASIC
define DEBUG_REG PORTA
define DEBUG_Bit 1
DEFINE DEBUG_BAUD 9600
DEFINE DEBUG_MODE 1
define PULSIN_MAX 1000

// snip //

' Code start
init:
pause 100 ' let things settle
debug "Start",10,13

Any ideas greatly appreciated.
Phil.

skimask
- 9th March 2008, 07:05
Code below for 16F737 compiles & runs just fine under PBP 2.46. Compile under 2.50a and everything runs OK *EXCEPT* DEBUG (nothing changes on debug pin).
Config fuses set the same between the 2 PBP versions?
Did you change something in the .inc file way back when and forget about it?

MPLAB 7.60. There is a newer version...not that it'll help anything...you never know...

Phil Moore
- 9th March 2008, 07:55
Hi Skimask,

I did change over from PM to MPASM as I was doing other stuff with 18F chips, however, the only config change I made to the 16F737.INC file was to set clock to INTRC with IO. This is the same config I had with PM:

' Device fuses & registers (Assumes PM assembler)
@ DEVICE INTRC_OSC,MCLR_ON,WDT_OFF


Fuses:
Osc - INTRC as IO
WDT - Off
PUT - Off
RE3/MCLR = MCLR
BODEN - Enabled
BODENV - 2.0V
Backbug - disabled
CCP2MUX - RC1
CP - Off
BORSEN - enabled
IESO - enabled
FCMEN - enabled

Device (DVD simulator - don't ask why) is powered off USB port of PC, with extra cap for filtering - don't think it's a voltage thing.

Cheers
Phil.

skimask
- 9th March 2008, 07:59
I don't see anything turning off the ANALOG function of PortA.1 and switching it over to digital...

Actually, yes I do see something turning off SOME analog ports, but not enough...

Phil Moore
- 9th March 2008, 08:51
Hi Skimask,

Changed ADCON1 to $f, but no joy (if that's what you meant).

Phil.

skimask
- 9th March 2008, 08:54
Hi Skimask,

Changed ADCON1 to $f, but no joy (if that's what you meant).

Phil.

Yep, you got it.
Try a different pin without any analog functions on it, just a plain ol' pin.
Try one of the SEROUT commands and see what happens.
Try a bunch of things...try anything.

Phil Moore
- 9th March 2008, 09:16
Skimask,
Also changed ADCON0 to 0 (just in case),
Serout2 works OK (same pin) but that's not the point!
Sanity rapidly departing, need to go away and have a think.
Thanks for your help - another brain always sees something different!
Cheers,
Phil.

skimask
- 9th March 2008, 09:28
Skimask,
Also changed ADCON0 to 0 (just in case),
Serout2 works OK (same pin) but that's not the point!
Sanity rapidly departing, need to go away and have a think.
Thanks for your help - another brain always sees something different!
Cheers,
Phil.

If SEROUT2 works, and DEBUG doesn't work, it's gotta be the way you config'd DEBUG
Check your upper/lower case...ALL CAPS on the DEFINE's
Check your modes...
Post your codes...
(hey that rhymes!!!)

NOTE: Changing ADCON0 isn't going to do anything to the pin. It's only going to shut off the A/D module.

skimask
- 9th March 2008, 09:35
Skimask,
Also changed ADCON0 to 0 (just in case),
Serout2 works OK (same pin) but that's not the point!
Sanity rapidly departing, need to go away and have a think.
Thanks for your help - another brain always sees something different!
Cheers,
Phil.

I think I see your problem back in the 1st post:



DEFINE OSC 8 ' Tell PicBASIC
define DEBUG_REG PORTA
define DEBUG_Bit 1
DEFINE DEBUG_BAUD 9600
DEFINE DEBUG_MODE 1


If this is the code you're using...what's wrong with this picture?
The problem is very subtle. I missed it a dozen times. Check page 31 of the manual.

Phil Moore
- 9th March 2008, 09:50
Yeah, saw that too, changed define to DEFINE both times (double checked with Notepad).
No joy.
I'm just going to stick with Serout2 for now - it's less painful! I'll sort out DEBUG later.
Thanks for all your posts!
Phil.

skimask
- 9th March 2008, 09:52
Yeah, saw that too, changed define to DEFINE both times (double checked with Notepad).
No joy.
I'm just going to stick with Serout2 for now - it's less painful! I'll sort out DEBUG later.
Thanks for all your posts!
Phil.

Keep trying...you're almost on top of it...
Show your code as it stands. You're....like....stepping in it....
Read the 3rd paragraph in that section again...and then again...and then re-read it again...
Then take a look at Page 56...and look at it closely...

Bruce
- 9th March 2008, 15:58
Change DEFINE DEBUG_Bit 1 to DEFINE DEBUG_BIT 1 and it should work.

Having the last 2 characters in lower case was making pin RA0 an output VS RA1.

At least is was in MPSIM. I don't have a 737 to test, but this works fine in MPSIM once
I change Bit to BIT.


@ __config _CONFIG1, _INTRC_IO & _MCLR_OFF & _DEBUG_OFF & _WDT_OFF & _CP_OFF


' Defines
DEFINE OSC 8
DEFINE DEBUG_REG PORTA
DEFINE DEBUG_BIT 1 ' note it's all UPPER CASE
DEFINE DEBUG_BAUD 9600
DEFINE DEBUG_MODE 1 ' 1 = inverted

' System Constants
OSCCON = $F0 ' set 8MHz internal
ADCON1 = $0F ' all digital
CMCON = 7 ' comparators disabled

' Code start
Init:
PAUSE 100 ' let things settle
DEBUG "Start",10,13
GOTO Init

END

There's a section in the library that sets up default values, and if something isn't
DEFINED, the value will be whatever the default is. In this case it's 0.

ifndef DEBUG_BIT ; Debug pin bit
DEBUG_BIT EQU 0

If wasn't seeing DEBUG_Bit as DEBUG_BIT so the default was RA0.

Phil Moore
- 17th March 2008, 09:41
Aaaaarrrrggggghhhhhh!

That was it - thanks Bruce & Skimask - make sure WHOLE DEFINE is in UPPERCASE.

Mutter, mutter, mutter! Too many IDEs, too many languages, not enough grey cells!

Again, thanks!

Phil.