Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Platform Independent Code

Status
Not open for further replies.

Sanath Embedded

Member level 3
Joined
Jan 23, 2009
Messages
57
Helped
4
Reputation
8
Reaction score
3
Trophy points
1,288
Activity points
1,676
Hi Guys,

I am writing an program for one application in C / C++ which should run on all target controller architecture like 8051 , AVR, PIC , MSP430 or ARM7 . How could I write this Platform Independent Code.

can anyone help me on this.
 

you should practice writing code in layered structure.. i meant you should write hardware-dependent code and hardware-independent code separately

for example.. check below code that sends string via UART

High-Level or Hardware-independent function
Code:
void putsUART(char *str)
{
      while(*str)
          putcUART(*str++);
}

low-level or Hardware-dependent function
Code:
void putcUART(char chr)
{
     //hardware dependent code
}

Here u can use High-level function in all architectures but u have to write Low-level function seperately for each architectures..

click helped button if i helped u
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top