View previous topic :: View next topic |
Author |
Message |
norman_tan
Joined: 30 Jan 2008 Posts: 27
|
How to let "sfr P0= 0x80;" command line pass compi |
Posted: Wed Mar 14, 2018 3:00 am |
|
|
Hi All,
I am integrating an old 51 project into my current CCS project, during compiling I have met many many Errors. and CCS support have given me much help. I am very thankful to them. they are great!
and at the same time, It will be better if I can get help or advices from you too, thus it will reduce the burden for CCS support . I am sorry there are too many Errors here.
How to let command line "sfr P0= 0x80;" in file "REG52.h" pass compiling and at the same save the original function?
Thanks a lot!
Norman |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19538
|
|
Posted: Wed Mar 14, 2018 4:15 am |
|
|
REG52.h was a register file for the old 80C51/2 processor.
Nothing to do with the PIC.
Now the obvious way is to simply use a #DEFINE and #IF statement/test.
First thing you need to work out is what the equivalent register is for the PIC involved. The P0 register on the 8051, is probably going to be closest to PortA on the PIC, but since it is a different chip this is really going to depend on the board hardware.
Then you would use something like:
Code: |
#if (defined(__ISNT_CCS__)
#include "REG52.h"
#else
#include "CCSREG.H"
#endif
|
Then in your CCSREG.h file you would define your replacement register with something like:
Code: |
#byte P0 = getenv("sfr:PORTA")
|
Which would give you a register 'P0', now talking to the PIC PORTA.
However you do have the major caveat, that the hardware is not going to be the same, so where you were talking to P0, the PIC pins may well be different, or may need to be different because different hardware is on the pins.... |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9241 Location: Greensville,Ontario
|
|
Posted: Wed Mar 14, 2018 5:49 am |
|
|
Having 'been there, done that' it may be easier to actually abandon the 'integration' method and just code 100% in CCS C. As Mr. T points out ports and pins are not the same (obviously) so a LOT of time will be used trying to 'convert' or 'integrate' 8051 code into PIC code.
In my case (20+ years ago...sigh), I made a chart of 8051 ports/pin vs PIC ports/pins, stuck it on the PC case and coded one 8051 program function at a time into CCS C.Had a dummy main() that called each function. Compiling would show any errrors (well typing, syntax, etc.), I'd correct/compile and move onto the next one. This technique took about a week and in the end the CCS C program did work.
In doing it this way you migrate from 8051 'design' philosophy into the PIC way of doing things. |
|
|
norman_tan
Joined: 30 Jan 2008 Posts: 27
|
|
Posted: Thu Mar 15, 2018 1:30 am |
|
|
Dear Ttelmah and Temtronic,
Both your said are good ideas, Thanks a lot!
In this OLD C31 project (I want to integrate it into my current CCS project), the Profibus chip (Siemens chip DPC31) includes two cores, one is ASIC and the other is C31. And its firmware package is edited based on the inner C31, so it calls C31 function easily. But now I want to use its ASIC function only. I hope DPC31 can call its inner C31 function itself, I think so, but I am not sure of it. So I am asking Siemens for this question too.
If it can be removed, it will be better.
Thanks. |
|
|
norman_tan
Joined: 30 Jan 2008 Posts: 27
|
|
Posted: Thu Mar 15, 2018 2:42 am |
|
|
Hi all,
Siemens answered as below:
when you use an external processor all codes of the C31 can be removed.
That is cooool.
Thanks!
Norman |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9241 Location: Greensville,Ontario
|
|
Posted: Thu Mar 15, 2018 5:55 am |
|
|
hmm
have you a copy of this ?
dpc31_hardware_description_v21.pdf
looks like THE datasheet for the device.
Jay |
|
|
norman_tan
Joined: 30 Jan 2008 Posts: 27
|
|
Posted: Thu Mar 15, 2018 8:17 pm |
|
|
Dear temtronic,
I have a copy of "dpc31_hardware_description_v25.pdf".
but I do not know how to attach it here
How about telling me your email address?
Norman |
|
|
|