📄 add8.c
字号:
/***********************************************************************TARGET MICROCONTROLLER : PIC16F877A
COMPILER : CCS-C COMPILER
PROGRAM : ADDITION OF TWO 8-BIT UNSIGNED NUMBERS WITH CARRY
ADD THE TWO HEX NUMBERS AND THE RESULT IS DISPLAYED IN PORTC AND PORTB.
THE NUMBERS ARE OXF6 AND 0XA4. THE ANSWER IS 0X19A. THE LOWER BYTE OX9A TO
BE DISPLAYED IN PORTC AND THE HIGHER BYTE OF CARRY 0X01 TO BE DISPLAYED IN PORTB
***********************************************************************/
#include <16F877A.h> // HEADER FILE
#use delay(clock=6000000)
#BYTE PORTC =0X07 // Define the all register address
#BYTE PORTB =0X06
#BYTE TRISA =0X85
#BYTE TRISB =0X86
#BYTE TRISC =0X87
#BYTE STATUS =0X03
#BIT C=0X03.0
//GLOBAL VARIABLE DECLARATION
int8 i,j,result;
#ZERO_RAM
void main(void) // Start the main program
{
TRISB = 0x00; // Direction register PortB as output
TRISC = 0x00; // Direction register PortC as output
PORTB = 0xFF; // Make portb as low
PORTC = 0xFF; // Make portc as low
i = 0XF6; // assign the value 0xf6 to variable i
j = 0XA4; // assign the value 0xA4 to variable j
result = i + j; // Add i,j and keep the answer in result //variable
if(C)
PORTB &= ~0x01; // Display the result in port c
PORTC &=~result; // Display carry in port b
//(make8 is built in function in ccs)
while(1);
} // End of main program
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -