Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

PIC16c assembly code

Status
Not open for further replies.

Topz

New Member
I'm just starting to learn about using PICs. I've been reading though several how to's and such but im a little confused. I have some machine code for a PIC16c that Im trying to understand, it seems pretty simple but it doesnt make sense to me..
Here is the code from MPLAB
1 000 84D RETLW 0x4d
2 001 8A0 RETLW 0xa0
3 002 874 RETLW 0x74
4 003 805 RETLW 0x5
5 004 8D7 RETLW 0xd7
6 005 851 RETLW 0x51
7 006 89E RETLW 0x9e
8 007 80A RETLW 0xa
9 008 864 RETLW 0x64
10 009 814 RETLW 0x14
11 00A 868 RETLW 0x68
12 00B 881 RETLW 0x81
13 00C 8B8 RETLW 0xb8
14 00D 8CC RETLW 0xcc
15 00E 814 RETLW 0x14
16 00F 81C RETLW 0x1c
17 010 82C RETLW 0x2c
18 011 8FC RETLW 0xfc
19 012 8D0 RETLW 0xd0


It looks like it is sending characters to a string? like its making a word?
 
I'm just starting to learn about using PICs. I've been reading though several how to's and such but im a little confused. I have some machine code for a PIC16c that Im trying to understand, it seems pretty simple but it doesnt make sense to me..
Here is the code from MPLAB
1 000 84D RETLW 0x4d
2 001 8A0 RETLW 0xa0
3 002 874 RETLW 0x74
4 003 805 RETLW 0x5
5 004 8D7 RETLW 0xd7
6 005 851 RETLW 0x51
7 006 89E RETLW 0x9e
8 007 80A RETLW 0xa
9 008 864 RETLW 0x64
10 009 814 RETLW 0x14
11 00A 868 RETLW 0x68
12 00B 881 RETLW 0x81
13 00C 8B8 RETLW 0xb8
14 00D 8CC RETLW 0xcc
15 00E 814 RETLW 0x14
16 00F 81C RETLW 0x1c
17 010 82C RETLW 0x2c
18 011 8FC RETLW 0xfc
19 012 8D0 RETLW 0xd0


It looks like it is sending characters to a string? like its making a word?

hi,
That looks like a part of a Table of values.
The RETLW 0Xnn are the values.

Usually the header code is at the start of the Table routine
This header code uses an input value which forms a pointer to the value in the Table.

Is this what you mean.?
 
Last edited:
As Eric says, it's part of a table - but not enough of one to work.

You're also not posting the source code, but part of one of the output files, the source would be far more useful.
 
okay, Here is the entire file.. Hopefully you guys can help me understand it. Its like its supplying a word, but what is the word. All I'm getting is something like MtQdh ???
 

Attachments

  • PIC.TXT
    142.1 KB · Views: 249
Don't you have the source coded for the program?, it's much more difficult understanding a crude disassembly then the original source code.

I'm presuming it's a VERY old program, as the 16C OTP chips are really antiques.
 
It also appears that the code starts execution at 0x7ff. Which pic is that?

Mike.
 
Don't you have the source coded for the program?, it's much more difficult understanding a crude disassembly then the original source code.

I'm presuming it's a VERY old program, as the 16C OTP chips are really antiques.

Sorry, No I dont have the source code. I just have a .hex and .bin for it. And yea its pretty old is came from a project in around 1995 I think. LOL
Its a 16c57, I wish I could change it to a 16f57 but I just get errors when I try to burn it to the 16f57.
Its from an old video game, Im just wanting to see what it does and hopefully make changes to it. If I can figure out what the word that it is supplying then I can change it to let me play other games.
 
Another question for you guys..
Can the configuration bits cause the chip to not work if they are set differently? The first time I burned one of these PICs I got a good working PIC, now everytime I try to burn one I get a programmed successful but the PIC doesnt work. I've been trying different config bits to see if I had something there different. I also updated MPLAB since then, could there have been a change that is causes it not to program the PIC correclty?
 
I don't understand why I can burn the PIC and get a Program Sucessful message, but then I can do a verify and get tons of errors? What could be causing this? I'm not write protecting the chip either.
 
Are you absolutely sure you're not code protecting it?, if it verifies during programming it should be correct, the config fuse, including code protection, are applied AFTER it's been verified during programming.
 
yea I'm sure, If I do a read of the PIC it doesnt give me the pic is code protected message.

Heres what Im doing(maybe im doing something wrong)
Im starting MPLAB
selecting my programmer (Picstart plus)
enabling programmer
selecting device (PIC16C57)
File>import (then choosing the .hex I need)
then Im hitting the program button (The config bits come up as RC,ON,OFF; although the PIC is a XT, Ive tried to change it to XT and it still doesnt work)
it tells me the PIC is not blank (its brand new??)
I hit ok and it programs
I get program /Verification sucessful message...

but if I hit verify right afterwards, I get erros and verify fail..??
 
Also, When I insert a brand new PIC and I do a blank check I get
PICSTART Plus Firmware Version 04.50.11

Device is NOT blank:
Program Memory
Configuration Bits

Why does that happen?
Thanks for all the help by the way!!
 
You mentioned eariler errors when you try writing to a 16F57 - are you now trying to write 16C57's and getting errors on those as well?.

I'm presuming you know that 16C57's are OTP?, and also that you have to order them specifically for the oscilllator type you require - what types of 57's are you using, and what oscillator are you using?.

You might also has a look at:

**broken link removed**
 
Yea Im only using the PIC16C57 right now, the 'F' model uses a different algorithm so im sure it wont work unless I could recompile the code for that model of chip.

I ordered the same exact model of chip its a PIC16C57-XT/P. Which is what mouser.com sent me. I wander if that link you posted is what is happening? It could be that these new PICS are not the same as the original ones and will not work.

I've made one that worked and I ordered it several months ago as a test sample. Then I ordered a few more that don't work. You would think that a few months wouldnt make a difference unless I got a different batch.
 
Right, so you're using a crystal oscillator, presumably 4MHz or so?.

When you get a brand new chip and read it, what do you get? - every memory location should read all ones.
 
Yes, theres a 4.0mhz crystal...
When I read it I get all F7F... I'm guessing thats all ones?
Is there another program I should try to use to burn these? Maybe the MPLAB is doing something thats causing the problem?
 
okay, I tried to program another PIC, programming seems okay as usual, but the pic still does not work. Heres the screen from MPLAB, when I hit 'program' I get a screen that says
Device NOT blank, Program Memory Configuration Bits (Even though it is blank??)
I programmed it and then did a verify

PICSTART Plus Firmware Version 04.50.11

Device is NOT blank:
Program Memory
Configuration Bits


PICSTART Program\Verify Report
30-May-2009, 17:35:04

Device Type: PIC16C57
Address Range 0-7ff


Programming/Verification completed successfully


PICSTART Program\Verify Report
30-May-2009, 17:35:18

Device Type: PIC16C57
Address Range 0-7ff


Program Memory Errors

Address Good Bad

0001: 08A0 0820
0004: 08D7 0857
0006: 089E 081E
000B: 0881 0801
000C: 08B8 0838
000D: 08CC 084C
0011: 08FC 087C
0012: 08D0 0850
001C: 0C87 0C07
0048: 04C7 0447
0049: 0996 0916
0059: 0AA9 0A29
005E: 0ACF 0A4F
0063: 05A3 0523
0069: 05A3 0523
006A: 0ABA 0A3A
006F: 05A3 0523
0070: 0AB0 0A30
0072: 06E7 0667
0075: 07FA 077A
0078: 0DE0 0D60
007D: 099F 091F
0080: 05C7 0547
0081: 02A4 0224
0087: 0990 0910
008A: 0990 0910
008B: 0388 0308
0091: 06E7 0667
0092: 0A90 0A10
0093: 0CFF 0C7F
0095: 04C7 0447
0097: 07E7 0767
Any additional errors are not displayed.
 
Yes, theres a 4.0mhz crystal...
When I read it I get all F7F... I'm guessing thats all ones?
Is there another program I should try to use to burn these? Maybe the MPLAB is doing something thats causing the problem?

It's a 12 bit device, when it's blank it should read all 'FFF', whereas the 14 bit devices read '3FFF' because of the extra two bits.

If it's reading 'F7F' then it's not blank, or at least not working correctly.

If you check the error log you posted, that's the problem, bit 7 is always zero.

Do you know someone else who has a PICStart+, who could check one of your blank chips for you?.
 
No I don't, I have a Willem and a Data I/O 3900, I'll check if one of those two can supports PICs.. I'm guessing that its the PicStart and not the new PICs from mouser.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top