Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
02/24/05 11:48
Read: times


 
#88310 - Portability No .. Commonality Maybe
Responding to: ???'s previous message
I totally agree with Erik that C code does not provide portability at the microcontroller level. The very nature of an embedded system in close relationship to the hardware indicates that any portability would only be available on identical platforms. Take for instance one project I worked on. I had C code from a Cygnal C8051F126 setup. I wanted to move a bunch of the code to a SiLabs C8951F020 platform. The code was not directly usable. Every place I/O with SFRs was referenced in the code needed to be changed....so much for portability.

I have one project I am involved with where in one system two different families of microcontrollers were used. One type is Atmel and the other a Renesas H8. Both microcontrollers have to run nearly identical functions and algorithms. As such much work has gone into making as much source code common as possible...but two different tool chains and two different project file structures are used. But you would be amazed at the number of tricks and pre-processor directives that are needed to get this to work. And as Erik mentions in his project we had to segment the I/O functions between the two platforms into a pair of separate source files that served as a HAL (hardware abstraction layer) wherein the naming of subroutines and global variables between the common shared source files and the HAL file were kept exactly the same. This system does now work and it does save time when now a "feature" is added that effects the whole system within the common source code. Note that in both cases the HAL code is about 1/3 of the total binary code on each platform! Call that portability? -- No way!!.

Rather what I have found C to be a useful embedded tool for is that I am able to write code for various types of processors wherein I can concentrate on the required algorithms rather than on the details of the underlying assembly language differences. In the early stages of a project with a new type of microcontroller I famlilarize myself with the I/O register structure, memory maps, and how the assembly language works. Then when I lay the use of a C compiler over this foundation I can write code that is suitable to the application at hand using a familar syntax and language structure.

Michael Karas




List of 20 messages in thread
TopicAuthorDate
Rotating Carry (CY) through ACC in C51            01/01/70 00:00      
   Why ?            01/01/70 00:00      
      It is a keyboard interface sub routine            01/01/70 00:00      
         A51 to C51 interfacing            01/01/70 00:00      
            inline            01/01/70 00:00      
               it does, but            01/01/70 00:00      
                  Nevertheless            01/01/70 00:00      
                     A Case in point            01/01/70 00:00      
   what?            01/01/70 00:00      
      Thank you.            01/01/70 00:00      
      Try            01/01/70 00:00      
   what?            01/01/70 00:00      
   shift first            01/01/70 00:00      
      Problem Solved            01/01/70 00:00      
         Wrong approach            01/01/70 00:00      
            using chainsaw to perform dental surgery            01/01/70 00:00      
               or...            01/01/70 00:00      
   ANSI C            01/01/70 00:00      
      microcontroller C portability is a myth            01/01/70 00:00      
         Portability No .. Commonality Maybe            01/01/70 00:00      

Back to Subject List