The code does alot of IO port operations. Keil uses SFR and SBIT declarations whereas the AVR code uses defines to set IO port locations and byte operations to set/clear/test bits. There has to be a better way than slogging through the text conversion and then slogging through the debug???
before you port the code, you need to understand how it relates to the underlying hardware.
Keil SFR and SBIT relate directly to the 8051 hardware - you're going to have to determine how the existing code relates to the AVR hardware, how that can be translated to 8051 hardware, and how that, in turn can be represented in software.
If minimizing code change is the priority, then you could continue to use #defines to reference the I/O port addresses, and byte operations to set bits. The 8051 provides byte-wide access to the I/O bits via the port SFR addresses (0x80, 0x90, etc). The bit operations are more efficient, but it's not the only way to set bits in a port.
True The IO is not particularly complicated, just alot of detail, which of course must be done perfectly. (8051 talks to a complicated SPI device)
In that case, the only processor-specific part should be the low-level SPI "driver" part, surely?
So write yourself a low-level AVR-Specific "driver", and a low-level 8051-Specific "driver". Give them both the same interface to the "upper" software, and write that software using only portable constructs.
Hello all just wondering what sort of multimeter i should buy i have about $20 but doubt i will need to spend that much i just want a fairly good all-rounder to testing small circuits nothing big or anything any ideas where to get one?
thanks will
You may be new to electronics, but what made you think that it would be appropriate to inject this question into a discussion about porting code from an AVR to an 8051?
In fact, what made you think it was appropriate to this forum at all?
Before posting to any forum, you should always check if your question is appropriate to that forum.
This forum is for the discussion of Keil products: http://www.keil.com/forum/
So you would probably be better off finding a general electronics forum.
At the very least, start a new thread - and explain how your requirement relates to Keil products.
guess you guys cant (or wont) help me :(
In the list of threads, this one appears as "porting C code from AVR to 8051" - so nobody is going to guess that there might be a question about multimeters buried in it, are they?
Why don't you just start a new thread, properly, and ask your question there?
Yes,
From an organizational perspective, it's not all SPI: There is an intrinsic routine on the AVR and needs to be added to 8051, and time of day which runs on the host.
Am left with two questions: 1) What optimizations should be expected from a C compiler for small microprocessor? (a new thread?) 2) Number of source files & their relation to the hardware and software structure?