[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

PIC 16F877A strange behaviour

From: Rob Gorbet   rbgorbetuwaterloo.ca
Date: Thu, 15 Feb 2007 23:14:46 -0800

A! Sent via the Art & Robotics Group mailing list: arg-list@xxxxxxxxxxxxxxx
R! Use your "Reply All" to  reply to the list, "Reply" for private response
G!

Hi all.

I'm developing a project using a 16F877A.  I'm 
clocking at 20MHz, compiling using CCS PCM 3.098
(old, I know), and programming using Shane Tolmie's 
bootloader and Bootloader+ v1.02 on the windows side
(www.microchipc.com/PIC16bootload).

The project includes a UART for debug info, and 
I do the standard flashing a LED on reset and printing
a "hello world" to show it's running.  I went through
dozens of increasingly complex code versions with the 
bootloader and testing over the UART and everything was 
fine.

Then, as the code became more complex/big, sometimes I 
started getting garbage over the UART when the code ran
after downloading.  On a reset, same thing.  Occasionally,
I would see snippets of my code being printed out the UART,
or the code would end up in places where it shouldn't be.

I suspected a RAM problem (too many variables overwriting
each other and possibly overwriting code).  My RAM usage
was listed as 55-85% in the LST file, so it was possible
I guess.  I went to 16-bit pointers to allow access to the
upper 256k of data memory, and that didn't solve the problem.
My ROM usage was near 25%, so lots of ROM.

I tried commenting out different portions of code, and there
seemed to be less impact based on what was commented rather
than how much.  So it seems the code is getting too big, despite
the stats on ROM and RAM usage.

Then I realized that as long as the code stayed in the first
page of ROM (i.e., fit below 0x0800), it behaved properly.
All the code which misbehaves has code above 0x0800, in page 1
of ROM.

Has anyone encountered this before?  Any thoughts as to why
or how to resolve it?  

This code needs to be done in the next couple of days and 
this has had me stymied for 2 days now.

Any help greatly appreciated.

Rob.


A!
R!      messages saved at http://www.interaccess.org/arg/arg-list.html
G!      unsubscribe/help requests to mailto:Majordomo@xxxxxxxxxxxxxxx