Home
Prox / RFID
Verichips
Ladder Logic
[interfacing] †
Tube Joints
Key Code From Photo
SolveSpace (3d CAD)
SketchFlat (2d CAD)
Photographs
Miscellany
Resume / Consulting
Contact Me

LDmicro Forum - PIC18 Implementation

(you are viewing a thread; or go back to list of threads)

PIC18 Implementation (by Goran Stojanovski)
Hi,

I have started to implement PIC18 in LD micro. According to the instructions, I have added the definition of the microcontroler (PIC18F4550) in mcutable.h, and created new pic18.cpp file (actually is a lot the same with the pic16.cpp in the moment).

I have added a line in makefile, and redirect the compiler to compilepic18 function in pic18.cpp.

After recompiling the code, I can see and select the new pic18 mcu, vut when I try to compile the .hex I get Internal error in pic18.cpp (line302)

301 case OP_MOVLW:
302 CHECK(arg1, 8); CHECK(arg2, 0);
303 return (3 << 12) | arg1;

At first I guessed that I have made something wrong, and copied the whole pic16.cpp in pic18.cpp, and changed only the function

void CompilePic16(char *outFile) -> void CompilePic18(char *outFile)

and some necessary if statements and still got the same result...

I guess I am missing something in the other files, but I'm to tired to continue now.

Anyway, if someone knows where is my mistake, I will be very grateful.
Sat Aug 8 2009, 07:13:12
(no subject) (by Jonathan Westhues)
Somewhere, you generated a MOVLW instruction with invalid operands: either arg1 was greater than 255 (i.e., more than 8 bits), or arg2 was non-zero (i.e., more than zero bits).

I would suggest that you test for that in Instruction(), to figure out where the bad instruction is getting generated. At that point the problem should be obvious.

Of course the assembler must get rewritten for PIC18 anyways. But MOVLW still takes a single 8-bit operand for PIC18, so the instruction that it's trying to assemble is still invalid.
Sat Aug 8 2009, 07:37:01
Help with writing hex file (by Goran Stojanovski)
Hi,

I've been busy lately, but now I am back and I will continue with my work on PIC18 micro controllers. I want to ask if someone knows where can I fins specifications about writing the HEX file. I have almost updated the instruction set (in fact only the basic instructions) for PIC18, and working on WriteHexFile routine.
Since the configuration word for PIC18 is a lot bigger than the one for pic16, I suppose that there are differences in the hex file.

Any suggestions?
Sat Sep 5 2009, 18:55:29
(no subject) (by Jonathan Westhues)
The PIC18 hex file format is almost the same as for the PIC16. The basic file format is in both cases Intel's IHEX. It basically just consists of addresses in program memory, followed by the code that should appear at those addresses.

The PIC16 instructions are 14 bits, so the two high bits of each two-octet word are zero. The PIC18 instructions are mostly 16 bits, so there's no padding, but it otherwise works the same. Though note that some PIC18 instructions are 32 bits; so you'll have to account for that correctly when calculating branch destination addresses, perhaps by adding an extra placeholder to the un-assembled program after any 32-bit op.

The configuration word just goes at a particular location in program memory, which the datasheet specifies. For example, the PIC18FXX2 has them starting at 300001h, per Table 19-1. Note that PIC16 locations are given in words, but the PIC18 are given in octets; so be careful of the factors of two.
Sat Sep 5 2009, 19:19:08
implementing PIC18 in LD micro (by Robert Baer)
I can only financially support this project, and to a limited degree since i am Socially Insecure.
However, if some funding is helpful and desirable, please let me know.
I have done programming, am reasonably decent in hand-optimizing, untying knots and cleaning up messes but "C" and its variants do not get along with me; FORTRAN, BASIC and assembly are more my style - if that is of any help.
Wed Sep 30 2009, 16:49:21
(no subject) (by André Faccioni)
I managed to get here, but for me also giving this internal error:
  OP_BCF case:
             CHECK (arg2, 3); CHECK (arg1, 7);
             return (4 << 10) | (Arg2 << 7) | arg1;
I am unable to understand this problem, because I am several days studying the code.
Can someone help me.
Mon May 23 2016, 10:45:02
Post a reply to this comment:
Your Name:
Your Email:
Subject:
(no HTML tags; use plain text, and hit Enter for a line break)
Attached file (if you want, 5 MB max):