What's wrong?

Hi all, I'm really losing my mind now, been fighting with this for 8 days now, I give up. I hope you can tell me what's wrong in my setup. :(
I self made a PIC18F8720 development board, and it seems to work, because I can program the chip with no problems.
I'm using 100 nF SMD capacitors near every Vdd (including AVdd), and an integrated clock oscillator. It's a 24 MHz CMOS part by Epson.
I wrote a simple test program which is supposed to set all ports to output (via the TRISx registers), and then put all of them to the "HIGH" logic level (via the PORTx registers).
This is my code, as shown by IC-Prog: 0000: D00F 0000 0000 0000 0000 0000 0000 0000 0008: 0000 0000 0000 0000 0000 0000 0000 0000 0010: 0000 0E00 6E92 6E93 6E94 6E95 6E96 6E97 0018: 6E98 6E99 6E9A 0000 0000 0000 0000 0000 0020: 0EFF 6E80 6E81 6E82 6E83 6E84 6E85 6E86 0028: 6E87 6E88 0000 0000 0000 0000 0000 0000 0030: D7DE 0000 0000 0000 0000 0000 0000 0000
And this is the configuration: Config1 = 2500 Config2 = 000F Config3 = 0080 Config4 = 0081 Config5 = C0FF Config6 = E0FF Config7 = 40FF ID Value = 0123456789ABCDEF
Is there anything wrong in my machine code (for this quick test I don't want to nor I think I need to install MP-Lab.. I tried it and hated it, I will write my own source level debugger and assembler and release it to the PD after I'm finished).
Is the reset vector ok? It's supposed to be a BRA to 0010, where it will meet a NOP (no reason in particular) and then the value 00 will be moved to W, which in turn will be moved to all the TRISx registers. Then W will be loaded with FF, which will be copied to all the PORTx registers. Finally (through some NOPs, again, just to leave some space for inserting other code for experiments) there's supposed to be a final BRA back to 0010. Addresses don't represent bytes, but instruction words.
I know it's tedious to go through machine code.. but if you're kind enough, and if the code or the configuration is wrong, please, can you point me to the errors?
Or, in alternative, could some kind soul post a small .HEX file with a demo program that just turns some port pins ON and some others OFF, just to see if my problem lies in my hardware or in my code?
I hope to get your valuable help.. I really don't know what to experiment else.
Kindest regards, Mike Forrest
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
Here is what's wrong:
http://www.catb.org/~esr/faqs/smart-questions.html
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
Your CONFIG1H register may be configured wrong. You have the MCU (acording to FOSC bits in this register) set to an External Clock. Since I don't know what oscillator you're using...this may or may not be correct. Additional info (datasheet on your oscillator) would be good. I have placed oscillator check as the last step, even though I think this might be the likeliest place to look. If you've done all this...do it again, just to humor me!
Debugging - Break out your digital multi-meter and o-scope, and follow this routine!
1) Is the chip recieving power? Check voltage on the chip supply pins (ALL of them!! From my experience, one unconnected VSS or VDD line will render the chip unable to function!) If not, power it up, see if it works, and if it doesnt, go to 2.
2) Check voltage levels on your output pins. Are they actually outputting the expected results? If they ARE outputting the expected value (VCC or ground), the problem is with your LEDs. make sure they're in the right way, and connected to the correct supply rail. If they STILL wont light up, either they're not recieve enough current to light (?!) or they're defective. test them, replace them, and all is well.
If there is nothing on the output pins, continue on to 3.
3) (at this point, its a hardware problem) Check the /MCLR line. Is it at VCC? If it's not, your MCU is never coming out of reset, and thus your program is not executing. Tie it to VCC as per the datasheet, and restart from step 2. If /MCLR is high, carry on to 4.
ICSP devices control the MCLR line during programming, which might explain why you can program, but not operate the device (Once the programming is finished, its up to you to control this line!!).
4) We need to confirm the oscillator is functioning. I believe this is where your problem lies. Ensure that your oscillator is running by hooking an o-scope up to it, or replacing your current oscillator with something you KNOW works (because you've actually used it before, and KNOW that it works...not because you got a schematic off the net!!)
In a worst case scenario (this is the only OSC you have, and you don't have an o-scope), hook up an RC circuit as per the datasheets, and reconfigure CONFIG1H as b'00100111' (switching off, external RC oscillator, OSC2 configured as GPIO RA6). If your chip works as expected, you need to ensure that you've used the CMOS osc correctly.
-Alex
snipped-for-privacy@invalid.com wrote:

Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
This is a multi-part message in MIME format. --------------080506000809060302000801 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit
Uhh. duh. hit send too early.
If you can CONFIRM that the oscillator is working correctly (through oscilliscope...don't be cheap and try to use your voltmeter on this), then the problem is in fact in your code. Since you've chosen to program directly in machine codes, instead of hex, you'll need to use the .HEX i've attached.
If everything is OK in hardware (everything CONFIRMED working), then load that hex onto the MCU, and use these config bits (Bare essentials)
These are listed with CONFIGxH first.
Config1 = H = 25 L = 00 (ex osc, osc switch disabled, Config2 = H = 00 L = 00 (brownout reset off, power up timer on, watchdog off) Config3 = H = 01 L = 83 (Microcontroller mode, bus wait off, RC1 is CCP2) Config4 = H = 00 L = 84 (Debugger off, LVP ON, Stack over/underflow off) Config5 = All relevant bits set. Config5 = All relevant bits set. Config6 = All relevant bits set.
The code in the hex will turn interrupts off, set porta as outputs, and load the data latch with FF. It then loops forever.
--------------080506000809060302000801 Content-Type: text/plain; name="DEBUGTEST.HEX" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="DEBUGTEST.HEX"
:020000040000FA :040000000EEF00F00F :0400080014EF00F001 :0800180014EF00F0806A000EF5 :0C002000926EF29EFF0E806E14EF00F056 :00000001FF
--------------080506000809060302000801--
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload

Polytechforum.com is a website by engineers for engineers. It is not affiliated with any of manufacturers or vendors discussed here. All logos and trade names are the property of their respective owners.