Searching \ for '[PIC]: Can't get this code working: PIC18F252' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/devices.htm?key=18F
Search entire site for: 'Can't get this code working: PIC18F252'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]: Can't get this code working: PIC18F252'
2003\01\30@064446 by Peter McNulty

picon face
Hi,

I'm just starting with this series but i can't get the simplest of things working, could you guyz tell me what I've done wrong.

Thanks
-Peter

############################################

errorlevel -306
list p=PIC18f252
include "c:\P18F252.inc"

CBlock
d1
d2
d3
EndC

org 0000
goto  Start

Init movlw b'00000000'
movwf TRISA ;all outputs
return
; 1 second delay
Delay
  ;4999993 cycles
movlw 0x2C
movwf d1
movlw 0xE7
movwf d2
movlw 0x0B
movwf d3
Delay_0
decfsz d1, f
goto $+2
decfsz d2, f
goto $+2
decfsz d3, f
goto Delay_0

  ;3 cycles
goto $+1
nop

  ;4 cycles (including call)
return


Start call Init

Main movlw b'00000001'
call Delay
call Delay
call Delay
call Delay
movlw b'00000000'
call Delay
goto Main
End

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email spam_OUTlistservTakeThisOuTspammitvma.mit.edu with SET PICList DIGEST in the body

2003\01\30@070722 by cdb

flavicon
face
On Thu, 30 Jan 2003 19:45:36 +0800, Peter McNulty wrote:
Delay_0
decfsz d1, f
goto $+2
decfsz d2, f
goto $+2
decfsz d3, f
goto Delay_0


Perhaps changing the goto's to BRA's and using labels might help? Or dcfsnz,f,banked though that one won't alter the Status register.

How are you using the access bank have you left it set as zero

I'll refrain from the obvious joke.

Colin
--
cdb, .....bodgy1KILLspamspam@spam@optusnet.com.au on 30/01/2003

I have always been a few Dendrites short of an Axon and believe me it shows.

Light travels faster than sound. That's why some people appear bright until they speak!

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email listservspamKILLspammitvma.mit.edu with SET PICList DIGEST in the body

2003\01\30@073037 by cdb

flavicon
face
I've just noticed you haven't told cblock where to go, so to speak.

cblock 0x000
di
d2
d3
endc

Colin
--
cdb, .....bodgy1KILLspamspam.....optusnet.com.au on 30/01/2003

I have always been a few Dendrites short of an Axon and believe me it shows.

Light travels faster than sound. That's why some people appear bright until they speak!

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email EraseMElistservspam_OUTspamTakeThisOuTmitvma.mit.edu with SET PICList DIGEST in the body

2003\01\30@073229 by Jinx

face picon face
Compiling this for the 16F628 seems to work OK. The timing
loop you have executes in 1 second @ 20MHz, and the whole
thing loops around over and over

Main movlw b'00000001'  << what is this for ? W gets over-
                                            << written by the 0X2c in
"delay"
call Delay
call Delay
call Delay
call Delay
movlw b'00000000'           << ditto
call Delay
goto Main
End

I thought it may be something to do with Cblock, but the RAM
in an 18Fxx2 starts at 0 doesn't it ?

As you've TRISed PortA are you trying to measure something
happening on a pin ? If this is being tried out in a chip you'd
need the other ports set, a CONFIG, and a check to see that
the PIC is actually running

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email listservspamspam_OUTmitvma.mit.edu with SET PICList DIGEST in the body

2003\01\30@073444 by Jinx

face picon face
> Main movlw b'00000001'  << W gets over-written by the
                                               << 0X2c in "delay"

You didn't leave out

    movwf   porta

did you ?

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email @spam@listservKILLspamspammitvma.mit.edu with SET PICList DIGEST in the body

2003\01\30@075309 by Quentin

flavicon
face
Also, adding to what other said:

> Delay_0
>  decfsz d1, f
>  goto $+2
This will only skip to next line in 18F, not over it (read up on how the
18F PC works). Should be goto $+4
>  decfsz d2, f
>  goto $+2
ditto
>  decfsz d3, f
>  goto Delay_0

Best to use labels, it can get pretty confusing in 18F if you use $+n.
--
Quentin
KILLspamqscKILLspamspamiptech.co.za
http://www.iptech.co.za

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email RemoveMElistservTakeThisOuTspammitvma.mit.edu with SET PICList DIGEST in the body

2003\01\30@080348 by

flavicon
face
How are you setting the CONFIG bits ?

Jan-Erik Söderholm

PS.
Use your ENTER key now and then so your lines will
be < 80 chars...
DS.


Peter McNulty wrote  :
>Hi,
>
>I'm just starting with this series but i can't
>get the simplest of things working, could you guyz
>tell me what I've donewrong.

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email spamBeGonelistservspamBeGonespammitvma.mit.edu with SET PICList DIGEST in the body

2003\01\30@082046 by Peter McNulty

picon face
I'm not setting the config bits, as I can't find any information on them.
There isn't much info in teh datasheet either.

Thanks for the info on the loops, I have changed those, and the
reflected code is below. Also, Jynx, after you're first message I just
saw that stupid mistake I made with PORTA. Changed that also, I've got
a feeling it isn't working because of the config bits. I'm checking them up
but any details would be appreciated.

-Peter


########################

errorlevel -306
list p=PIC18f252
include "c:\P18F252.inc"

CBlock
CounterA
CounterB
CounterC
EndC


org 0000
goto  Start

Init movlw b'00000000'
movwf TRISA ;all outputs
return

;PIC Time Delay = 1.0000006 s with Osc = 20.000000 MHz

Delay_1  movlw D'26'
movwf CounterC
movlw D'119'
movwf CounterB
movlw D'85'
movwf CounterA
call DoDelay
return

DoDelay decfsz CounterA,1
goto DoDelay
decfsz CounterB,1
goto DoDelay
decfsz CounterC,1
goto DoDelay
return


Start call Init

Main movlw b'00000001'
movwf PORTA
call Delay_1
call Delay_1
call Delay_1
call Delay_1
movlw b'00000000'
movwf PORTA
call Delay_1
goto Main
End



{Original Message removed}

2003\01\30@092626 by Josh Koffman

flavicon
face
Well, I don't think you can get away with just "not setting" the config
bits. Check in the include file, it will lay it all out as to what can
be set. In the 18F includes there are also a couple of examples I
believe. Be warned that it's not as easy as it is on the 16F chips,
there are many more options.

Josh
--
A common mistake that people make when trying to design something
completely foolproof is to underestimate the ingenuity of complete
fools.
       -Douglas Adams

Peter McNulty wrote:
>
> I'm not setting the config bits, as I can't find any information on them.
> There isn't much info in teh datasheet either.

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email TakeThisOuTlistservEraseMEspamspam_OUTmitvma.mit.edu with SET PICList DIGEST in the body

2003\01\30@101119 by Peter McNulty

picon face
Hi,

From what I gathered, I have to do something like this:

_OSCS_OFF_1H       EQU  H'FF'
_HS_OSC_1H         EQU  H'FA'
_CONFIG1H        EQU    H'300001'

__CONFIG    _CONFIG1H, _OSCS_OFF_1H & _HS_OSC_1H

This is to set HS Oscill at 20 Mhz, crystal...and turn Osc switching off.
However, It doesn't program the chip due to some error. Do you have an
example of the config your any of your programs.

-Peter
{Original Message removed}

2003\01\30@105036 by

flavicon
face
Check the examples in te MCHIP_TOOL\Examples\Code
directory where MPLAB is installed.

Amd specify *all* bits either on or off or whatever.
You might be hit by an unexpected default...

Jan-Erik Söderholm.

{Original Message removed}

2003\01\30@155448 by Jinx

face picon face
> a feeling it isn't working because of the config bits

> Thanks for the info on the loops

You can compile and run it in MPLAB without a CONFIG
to test the timing with Stopwatch.

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email RemoveMElistservspamTakeThisOuTmitvma.mit.edu with SET PICList DIGEST in the body

2003\01\30@191012 by Olin Lathrop

face picon face
>>
I'm just starting with this series but i can't get the simplest of things
working, could you guyz tell me what I've done wrong.
<<

Two problems:  Total lack of comments, and use of quoted printable in your
message making it a hassle to reply to in detail.


*****************************************************************
Embed Inc, embedded system specialists in Littleton Massachusetts
(978) 742-9014, http://www.embedinc.com

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email listservEraseMEspam.....mitvma.mit.edu with SET PICList DIGEST in the body

2003\01\30@191614 by Olin Lathrop

face picon face
> I'm not setting the config bits, as I can't find any information on
them.

So you think it's OK to ignore them just because you don't know what to do
with them!!?  Would you connect the PIC to +12V just because you didn't
look hard enough to find the Vdd spec?

And yes there is extensive information about them in the manual.  See
section 19.1 "Configuration Bits" on page 193 of DS3956A "PIC18Fxx2 Data
Sheet".


*****************************************************************
Embed Inc, embedded system specialists in Littleton Massachusetts
(978) 742-9014, http://www.embedinc.com

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email EraseMElistservspammitvma.mit.edu with SET PICList DIGEST in the body

2003\01\31@082421 by Peter McNulty
picon face
ooooooooh you think you're so smart don't you?!? No wonder
everyone of this list hates you so much and always disses you!

On topic: I've read the information you wrote before, however,
it still does not give information on configuring it in code. Only tells
about table reads, and from sample code, this is not what is done.

Does anyone have just a simple flashing LED program for the
18F252 or 18F452 series? It'd be really helpful, as there's
not that much info on the 18Fxxx series on the web yet.

Thanks
-Peter

{Original Message removed}

2003\01\31@083510 by Wouter van Ooijen

face picon face
> Does anyone have just a simple flashing LED program for the
> 18F252 or 18F452 series? It'd be really helpful, as there's
> not that much info on the 18Fxxx series on the web yet.

http://www.voti.nl/wisp628 : flash a LED for all flash PICs you are
likely to get your hands on.

Wouter van Ooijen

-- -------------------------------------------
Van Ooijen Technische Informatica: http://www.voti.nl
consultancy, development, PICmicro products

--
http://www.piclist.com hint: To leave the PICList
RemoveMEpiclist-unsubscribe-requestEraseMEspamEraseMEmitvma.mit.edu>

2003\01\31@084120 by Peter McNulty

picon face
Hi,

I can get this working fine and i first tested it with this. The problem
is, as it is compiled
from Jal, the code is hard to read. I'll give it another go soon.

-Peter
{Original Message removed}

2003\01\31@102313 by Hazelwood Lyle

flavicon
face
> I'm not setting the config bits, as I can't find any information on
them.

This is a short bit from a working 18F458 program.
There were some CONFIG bits that were not defined
in the include file. I don't know the intention behind
this, possibly they want them set from MPLAB project
and not from the source code.
Being an ignorant cuss, I added them myself.
I tried searching my recent posts to find the info on
that, but apparently I did it from home (other account)

Anyway, here's something that works for me.
It's for an 18F458, not a 252 as you need, but something close is better
than
nothing at all. YMMV

; '__CONFIG' directive is used to embed configuration data within .asm
file.
; The labels following the directive are located in the respective .inc
file.
; See respective data sheet for additional information on configuration
word.

       __CONFIG        _CONFIG1L, _CP_OFF_1L
       __CONFIG        _CONFIG1H, _OSCS_OFF_1H & _HS_OSC_1H
       __CONFIG        _CONFIG2L, _BOR_ON_2L & _BORV_42_2L &
_PWRT_ON_2L
       __CONFIG        _CONFIG2H, _WDT_OFF_2H & _WDTPS_128_2H
       __CONFIG        _CONFIG4L, _STVR_ON_4L & _LVP_OFF_4L &
_BKDB_OFF_4L


Lyle

--
http://www.piclist.com hint: To leave the PICList
RemoveMEpiclist-unsubscribe-requestspam_OUTspamKILLspammitvma.mit.edu>

2003\01\31@113152 by

flavicon
face
And here is a working 18F252 example :

       processor       18f252
       LIST            P=PIC18F252, b=4, n=45
       #include        <p18f252.inc>
       __CONFIG        _CONFIG1L, 0x00
       __CONFIG        _CONFIG1H, 0x27 & _OSCS_OFF_1H & _HS_OSC_1H
       __CONFIG        _CONFIG2L, 0x0F & _BOR_OFF_2L & _BORV_20_2L & _PWRT_OFF_2L
       __CONFIG        _CONFIG2H, 0x0F & _WDT_OFF_2H & _WDTPS_128_2H
       __CONFIG        _CONFIG3L, 0x00
       __CONFIG        _CONFIG3H, 0x01 & _CCP2MX_ON_3H
       __CONFIG        _CONFIG4L, 0x85 & _STVR_ON_4L & _LVP_OFF_4L & _DEBUG_OFF_4L
       __CONFIG        _CONFIG4H, 0x00
       __CONFIG        _CONFIG5L, 0x0F & _CP0_OFF_5L & _CP1_OFF_5L & _CP2_OFF_5L & _CP3_OFF_5L         __CONFIG        _CONFIG5H, 0xC0 & _CPB_OFF_5H & _CPD_OFF_5H
       __CONFIG        _CONFIG6L, 0x0F & _WRT0_OFF_6L & _WRT1_OFF_6L & _WRT2_OFF_6L & _WRT3_OFF_6L         __CONFIG        _CONFIG6H, 0xE0 & _WRTC_OFF_6H & _WRTB_OFF_6H & _WRTD_OFF_6H
       __CONFIG        _CONFIG7L, 0x0F & _EBTR0_OFF_7L & _EBTR1_OFF_7L & _EBTR2_OFF_7L & _EBTR3_OFF_7L
       __CONFIG        _CONFIG7H, 0x40 & _EBTRB_OFF_7H        


Jan-Erik Söderholm.

--
http://www.piclist.com hint: To leave the PICList
RemoveMEpiclist-unsubscribe-requestTakeThisOuTspamspammitvma.mit.edu>

2003\01\31@115750 by Jon M (Mike) Jones

picon face
You might try the following as a starting point;

include <p18F452.inc>
__CONFIG _CONFIG1H, _OSCS_OFF_1H & _HSPLL_OSC_1H
__CONFIG _CONFIG2L, _BOR_OFF_2L & _PWRT_ON_2L
__CONFIG _CONFIG2H, _WDT_OFF_2H
__CONFIG _CONFIG3H, _CCP2MX_ON_3H
__CONFIG _CONFIG4L, _STVR_OFF_4L & _LVP_OFF_4L & _DEBUG_OFF_4L

I ignored the code protection bytes as the default, no protection, seemed
correct.
I may still be missing something but this has been working, for me, quite
well.

Note that the 4X PLL is turned on in _CONFIG1H,  you may or may not want
this.

It took me a while to get the config bits understood and configured but with
the data sheet, section 19, in one hand and the include file, p18F452.inc,
in the other I arrived at something that worked. The information contained
in the include file was definitely the most useful in terms of getting the
syntax and options correct.

Hope this helps

Mike Jones

{Original Message removed}


'[PIC]: Can't get this code working: PIC18F252'
2003\02\01@003743 by Peter McNulty
picon face
Thanks A LOT! This worked perfectly, I had something like this, but
couldn't get it working.
BTW, in the 'list' directive, what do the 'b' and 'n' parts stand for? I've
never seen them in use
before.

-Peter
{Original Message removed}

2003\02\01@080702 by Olin Lathrop

face picon face
> BTW, in the 'list' directive, what do the 'b' and 'n' parts stand for?
I've
> never seen them in use
> before.

I suspect they do exactly what the manual says they do.

RTFM, "MPASM User's Guide with MPLINK and MPLIB" (DS33014G), page 58,
section 5.38 "LIST - Listing Options".


*****************************************************************
Embed Inc, embedded system specialists in Littleton Massachusetts
(978) 742-9014, http://www.embedinc.com

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads

2003\02\01@160536 by

flavicon
face
Or, so you don't have to lift your fingers from the keyboard,
the online help in MPLAB...

Jan-Erik Söderholm.

Olin Lathrop wrote :
>
>I suspect they do exactly what the manual says they do.
>
>RTFM,...
>

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads

More... (looser matching)
- Last day of these posts
- In 2003 , 2004 only
- Today
- New search...