AllExperts > Experts 
Search      

C

Volunteer
Answers to thousands of questions
 Home · More Questions · Answer Library  · Encyclopedia ·
More C Answers
Question Library

Ask a question about C
Volunteer
Experts of the Month
Expert Login

Awards

About Us
Tell friends
Link to Us
Disclaimer

 
 
 
 
About Mohamed Ameer Irshad.H
Expertise
can ask me questions regarding general concepts,algorithms in C.STLs(c++)TSR programmin,virus writing,basic level of device driver programming(linux),network programmming(UNIX C) ,UNIX shell scripting,grapihcs using TURBO C and a bit of hardware interaction..

Experience
just a student level experience but hav worked out of my academic contexts..

Organizations
Vellore Institute of Technology(University Of VIT)

Publications
Technical Publication Of NACISS(National Conference On Computational Intelligence and Security Systems)

Paper titled REMOTE DESKTOP ACCESS USING MOBILE PHONES AND AN ENHANCEMENT FOR INTRA-MOBILE SEARCH got selected in an international conference SNPD 2008,Thailand.And the paper will be published IEEE Journal by August 2008.

Paper titled REMOTE DESKTOP ACCESS USING MOBILE PHONES AND AN ENHANCEMENT FOR INTRA-MOBILE SEARCH got selected in International Conference on Information and Communication Technologies(ICT 2008) Paris,France.The same will be published in Proceedings of World Academy of Science, Engineering and Technology, Volume 30, July 2008. Education/Credentials
did a few courses in comp institutions in C and a few projects

Awards and Honors
Presented Papers in National Conferences

 
   

You are here:  Experts > Computing/Technology > C/C++ > C > hardware interaction

Topic: C



Expert: Mohamed Ameer Irshad.H
Date: 3/18/2008
Subject: hardware interaction

Question
what are all the variuos ways to interact with hardware using C?i read few books about this but dint understand properly

Answer
actually there are a lot of ways to interact with the hardware.
i guess you are asking about "LED Blinking" in embedded systems.
for this puropse you need to use specific boards like motorola,arm boards,etc and you have specific compilers like Borland,Codewarrior,etc.
for eg:
the following code is to test 89C2051 circuit
/*
* myfirst.c
* First C program for 2051 experiment
* complement P1.7 every 0.5 sec
* Copyright (C) 1999 Wichit Sirichote
* compiled with Dunfield Micro-C for 8051 Release 3.2
*/

#include c:\mc\8051io.h  /* include i/o header file */
#include c:\mc\8051reg.h

extern register char cputick; // cputick was incremented every 10ms
register unsigned char sec100,flag1;

#define n 50

task1();  // functions declarations
task2();

main()
{
        flag1 = 0;
        sec100 = 0;
        serinit(9600); // set timer0 to be 16 bit counter
        while(1){

             while(cputick == 0)
              ;
              cputick = 0;
              task1();
              task2();
                }
}

task1()                        // set bit 0 of flag1 every n*10ms
{
        sec100++;            // increment sec100
        if (sec100 >= n)
             {sec100 = 0;    // clear sec100
              flag1 |= 0x01; // set bit 0 of flag1
              }
}

task2()
{
       if ((flag1 & 0x01) != 0) // execute below if bit 0 of flag1 is set
              {
              // P1 ^= 0x80;    // exclusive or the latch bit 7 with 0x80
               asm " CPL P1.7"; // complement P1.7
               flag1 &= ~0x01;  // clear bit 0 of flag1
              }
}


another type of hardware interaction can be done through TSR programming and it works only in DOS mode(which may not be useful for present situations).
using TSR programming one can interact with the keyboard,printer,VDU and access processor's registers.

for eg:
to turn on caps lock:
#include<dos.h>
int main()
{
char far *p;
p=(char far *)0x417;
*p=64;
return 0;
}


//to write into the vdu memory

#include<stdio.h>
int main()
{
char far *v;
int i;
v=(char far *)0xb8000000l;
for(i=0;i<1000;i++)
*(v+i)='a';
return 0;
}


if i wasnt clear with my answer feel free to ask again.
all the best
Ameer Irshad


Add to this Answer    Ask a Question



  Rate this Answer
   Was this answer helpful?
Not at allDefinitely              
   12345  

     
About Us | Advertise on This Site | User Agreement | Privacy Policy | Help
Copyright  © 2008 About, Inc. About and About.com are registered trademarks of About, Inc. The About logo is a trademark of About, Inc. All rights reserved.