PIC16F818的IO.不能位操作
那位大佬指点一下!谢谢
/*
* File: main.c
* Author: Administrator
*
* Created on 2021年6月15日, 上午10:15
*/
// PIC16F818 Configuration Bit Settings
// 'C' source line config statements
// CONFIG
#pragma config FOSC = INTOSCIO // Oscillator Selection bits (INTRC oscillator; port I/O function on both RA6/OSC2/CLKO pin and RA7/OSC1/CLKI pin)
#pragma config WDTE = OFF // Watchdog Timer Enable bit (WDT disabled)
#pragma config PWRTE = OFF // Power-up Timer Enable bit (PWRT disabled)
#pragma config MCLRE = OFF // RA5/MCLR/VPP Pin Function Select bit (RA5/MCLR/VPP pin function is digital I/O, MCLR internally tied to VDD)
#pragma config BOREN = OFF // Brown-out Reset Enable bit (BOR disabled)
#pragma config LVP = OFF // Low-Voltage Programming Enable bit (RB3/PGM pin has digital I/O function, HV on MCLR must be used for programming)
#pragma config CPD = OFF // Data EE Memory Code Protection bit (Code protection off)
#pragma config WRT = OFF // Flash Program Memory Write Enable bits (Write protection off)
#pragma config CCPMX = RB2 // CCP1 Pin Selection bit (CCP1 function on RB2)
#pragma config CP = OFF // Flash Program Memory Code Protection bit (Code protection off)
// #pragma config statements should precede project file includes.
// Use project enums instead of #define for ON and OFF.
#include <xc.h>
#include <PIC16F818.H>
void main(void) {
OSCCON=0x74;
TRISB=0b00000000;//SEG:a~h
TRISA=0b00010000;//NTC-RA4
RA0=1;
RA1=1;
RA3=1;
RA6=1;
RA7=1;
while(1){
TRISB=0b00000000;//SEG:a~h
TRISA=0b00010000;//NTC-RA4
PORTB=0xff;
PORTA=0b01111011;//0x7f;//RA0=0;RA1=RA3=RA6=RA7=1;
}
return;
}
|