Re: 關於pic16F1526 I/O相關問題

作者 onekill 於 2018年03月19日 11:27:16
Hi AdamSyu,

可以提供部分線路跟程式
因為只是先寫簡單初始化動作而已

初始化副程式部分
void hardware_init(void){
INTCON = 0x00;//INTERRUPT CONTROL REGISTER

PIE1 = 0x01;//PERIPHERAL INTERRUPT ENABLE REGISTER 1
OSCCON = 0b01101000;//OSCILLATOR CONTROL REGISTER

OPTION_REG = 0x10000111;

//AD
ADCON0=0B01101101;
ADCON1=0B10110011;


ANSELA = 0b00101111;
TRISA = 0b11111111;


ANSELB = 0b00111111;
TRISB = 0b11111111;


// PORTC 因為沒有AD 所以沒有ANSELC暫存器
TRISC = 0b00000000;
LATC = 0b00111100;


ANSELD = 0b00001111;
TRISD = 0b00001111;
LATD = 0b01100000;


ANSELE = 0b00000111;
// ANSELE = 0b00000001;
//ANSELE = 0b00000001;
TRISE = 0b00000111;
//LATE = 0b11000000;
LATE = 0b00000000;//Black 20170718


ANSELF = 0b01101011;
TRISF = 0b01101011;
LATF = 0x00010100;


ANSELG = 0b00000000;
TRISG = 0b00101110;
LATG = 0b00000000;

FVRCON = 0x93;

//TMR1IE=0; //Disalbe
TMR1IE=1; //Enable
TMR1IF=0; //Flag clear

T1CON = 0b00000001; //
INTCON=0b11000000;//INTERRUPT CONTROL REGISTER

CCP1CON = 0b00000000; //開機off
TMR1 =(65536-1000); //1ms

}


引用:

AdamSyu 寫道:
方便的話, 提供下線路圖與程式, 便於判讀..
感謝..^^

來自: http://www.microchip.com.tw/newbb/viewtopic.php?forum=1&topic_id=22228&post_id=77858