Tutorial Microcontroller MCS-51 ATMEL ISP

Pelatihan Mikrokontroller

 

Microcontroller Kits

Programmer and Target 89s51

Simple Mikrokontroller 89s51 Trainer


Standart
Mikrokontroller 89s51 Trainer

Super Mikrokontroller Trainer 89s51

 

 

 

BACK

Summing Port 0 and Port 1 with C Programming

 

 

/************************************
           **
           ** A program to get familer with SDCC
           **
           ** This program will read port 0 and port 1
           ** and will add the their contents. Then it checks
           ** whether the result is greater than 127 or not. If it is
           ** greater than 127 then the addition result would be
           ** put to port 3 else to port 2. 
           ** Compiler : MIDE-51
*************************************/
#include <8051.h>
void main(void)
           {
           unsigned char a, b, c;
 a=P0;
           b=P1;
           c=a+b;
 if (c<127)
           P2=c;
           else
           P3=c;
 return;
           }

Comments, questions and discussion about this topic

BACK