CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

How to let "sfr P0= 0x80;" command line pass compi

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
norman_tan



Joined: 30 Jan 2008
Posts: 27

View user's profile Send private message

How to let "sfr P0= 0x80;" command line pass compi
PostPosted: Wed Mar 14, 2018 3:00 am     Reply with quote

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 Smile Smile
Ttelmah



Joined: 11 Mar 2010
Posts: 19195

View user's profile Send private message

PostPosted: Wed Mar 14, 2018 4:15 am     Reply with quote

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: 9081
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Wed Mar 14, 2018 5:49 am     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Mar 15, 2018 1:30 am     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Mar 15, 2018 2:42 am     Reply with quote

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: 9081
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Thu Mar 15, 2018 5:55 am     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Mar 15, 2018 8:17 pm     Reply with quote

Dear temtronic,

I have a copy of "dpc31_hardware_description_v25.pdf".

but I do not know how to attach it here Sad

How about telling me your email address?

Norman
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group