EmbeddedRelated.com
Forums
The 2024 Embedded Online Conference

Convert / recompile code - 16F84 to 16F628 need help!

Started by Shawn McClintock January 21, 2004
I have C source for a project, it was written for the 16F84. I am trying
to recompile using Hi-Tec to use the code on a 16F628 so I can add a few
routines myself (the code uses most of the 84's mem space) but even
after selecting the type of pic to compile for, the resulting HEX file
will not work on my 628. I have tried some simple 'blink a LED' sources
with same trouble.. 84 blinks, 628 wont.

What do I need to do to port my code to a 628? Obviously I am missing
something here.

Thanks in advance!

Shawn



Are you using a Port A bit for your LED drive?

Port A on the '628 comes out of reset configured as analog inputs. You
need to setup the CMCON register for digital I/O when you initialize
Port A. That's one of the common "gotchas" that often comes up when
porting software from earlier PICs to the '628.

Just a shot in the dark ...

Matt Pobursky
Maximum Performance Systems

On Wed, 21 Jan 2004 20:44:26 -0600, Shawn McClintock wrote:
>I have C source for a project, it was written for the 16F84. I am
>trying to recompile using Hi-Tec to use the code on a 16F628 so I can
>add a few routines myself (the code uses most of the 84's mem space)
>but even after selecting the type of pic to compile for, the
>resulting HEX file will not work on my 628. I have tried some simple
>'blink a LED' sources with same trouble.. 84 blinks, 628 wont.
>
>What do I need to do to port my code to a 628? Obviously I am missing
>something here.




maybe you've already done this but have you verified that the 628
hardware works?

are you using the same config bits between the 628 and 84? are you
using FOSC=RC, by chance? in the 628 there's an additional Fosc bit
that's in the same place as one of the CP bits in the 84.

When faced with this sort of thing and its got +V, I put a scope
probe on the xtal leads to see if its got oscillation. Then I write
a tiny little program that toggles an output pin for an LED (er,
scope probe).

good luck

--- In , "Shawn McClintock" <kd6oji@v...>
wrote:
> I have C source for a project, it was written for the 16F84. I am
trying
> to recompile using Hi-Tec to use the code on a 16F628 so I can add
a few
> routines myself (the code uses most of the 84's mem space) but even
> after selecting the type of pic to compile for, the resulting HEX
file
> will not work on my 628. I have tried some simple 'blink a LED'
sources
> with same trouble.. 84 blinks, 628 wont.
>
> What do I need to do to port my code to a 628? Obviously I am
missing
> something here.
>
> Thanks in advance!
>
> Shawn





Yes, the hardware is working with the 84. as far as config bits, extosc,
no watchdog, etc, I figured the programming software would know the
difference and apply correct bit flags. But thanks for the input, I will
check into it.

Shawn -----Original Message-----
From: Phil [mailto:]
Sent: Wednesday, January 21, 2004 11:11 PM
To:
Subject: [piclist] Re: Convert / recompile code - 16F84 to 16F628 need
help! maybe you've already done this but have you verified that the 628
hardware works?

are you using the same config bits between the 628 and 84? are you
using FOSC=RC, by chance? in the 628 there's an additional Fosc bit
that's in the same place as one of the CP bits in the 84.

When faced with this sort of thing and its got +V, I put a scope
probe on the xtal leads to see if its got oscillation. Then I write
a tiny little program that toggles an output pin for an LED (er,
scope probe).

good luck

--- In , "Shawn McClintock" <kd6oji@v...>
wrote:
> I have C source for a project, it was written for the 16F84. I am
trying
> to recompile using Hi-Tec to use the code on a 16F628 so I can add
a few
> routines myself (the code uses most of the 84's mem space) but even
> after selecting the type of pic to compile for, the resulting HEX
file
> will not work on my 628. I have tried some simple 'blink a LED'
sources
> with same trouble.. 84 blinks, 628 wont.
>
> What do I need to do to port my code to a 628? Obviously I am
missing
> something here.
>
> Thanks in advance!
>
> Shawn


to unsubscribe, go to http://www.yahoogroups.com and follow the
instructions


I think you found my problem. I am using portA for my LED indicators. I
will look and see what I would need to stuff in that register to clear
it and run as I/O.

Thanks!

Shawn -----Original Message-----
From: Matt Pobursky [mailto:]
Sent: Wednesday, January 21, 2004 10:29 PM
To:
Subject: Re: [piclist] Convert / recompile code - 16F84 to 16F628 need
help! Are you using a Port A bit for your LED drive?

Port A on the '628 comes out of reset configured as analog inputs. You
need to setup the CMCON register for digital I/O when you initialize
Port A. That's one of the common "gotchas" that often comes up when
porting software from earlier PICs to the '628.

Just a shot in the dark ...

Matt Pobursky
Maximum Performance Systems

On Wed, 21 Jan 2004 20:44:26 -0600, Shawn McClintock wrote:
>I have C source for a project, it was written for the 16F84. I am
>trying to recompile using Hi-Tec to use the code on a 16F628 so I can
>add a few routines myself (the code uses most of the 84's mem space)
>but even after selecting the type of pic to compile for, the
>resulting HEX file will not work on my 628. I have tried some simple
>'blink a LED' sources with same trouble.. 84 blinks, 628 wont.
>
>What do I need to do to port my code to a 628? Obviously I am missing
>something here.


to unsubscribe, go to http://www.yahoogroups.com and follow the
instructions



At 07:44 PM 1/21/2004, Shawn McClintock wrote:
>I have C source for a project, it was written for the 16F84. I am trying
>to recompile using Hi-Tec to use the code on a 16F628 so I can add a few
>routines myself (the code uses most of the 84's mem space) but even
>after selecting the type of pic to compile for, the resulting HEX file
>will not work on my 628. I have tried some simple 'blink a LED' sources
>with same trouble.. 84 blinks, 628 wont.
>
>What do I need to do to port my code to a 628? Obviously I am missing
>something here.

The first order of business is to take a close look at both data
sheets. Your initial problem is probably that you are not configuring
register CMCON - this causes some of the pins on port RA to be in analog
mode. The fix is to write 0x07 to CMCON - this puts the affected pins back
to digital mode.

Another issue may be RAM bank problems - the 'F84 has a single RAM area
that is mapped into both bank 0 & bank 1. That means that you can take
shortcuts: you can access a user variable on bank 0 even though bit RP0 is
set. You can't do this with the 'F628 - there are 4 RAM banks with a total
of 224 bytes of RAM vs 35 bytes of RAM for the 'F84 or 68 bytes of RAM for
the 'F84A. Also note that the addresses for accessing and writing data
eeprom have changed (different banks as well).

Finally, check where your user RAM variables are located: user RAM starts
at address 0x0C for the 'F84(a) but at address 0x20 for the 'F628. If the
variable addresses are hard-coded, you will have to dig in and fix it.

dwayne

--
Dwayne Reid <>
Trinity Electronics Systems Ltd Edmonton, AB, CANADA
(780) 489-3199 voice (780) 487-6397 fax

Celebrating 19 years of Engineering Innovation (1984 - 2003)
.-. .-. .-. .-. .-. .-. .-. .-. .-. .-
`-' `-' `-' `-' `-' `-' `-' `-' `-'
Do NOT send unsolicited commercial email to this email address.
This message neither grants consent to receive unsolicited
commercial email nor is intended to solicit commercial email.



The 2024 Embedded Online Conference