Browsing this Thread:
1 Anonymous Users
Topic options
View mode
舊的在前
Re: PIC16F18325 RA5設為輸出沒反應
管理員
Joined
: 2020/10/5 9:43最後登入時間
: 1/28 20:28
Group:
站務管理者
Level : 9
HP : 0 / 202
MP : 34 / 2059
EXP : 10
#define LED_B RA1 修正-> #define LED_B LATAbits.LATA1 #define RH_LED_B RA5 修正-> #define RH_LED_B LATAbits.LATA5
發表於: 2021/3/5 17:41
PIC16F18325 RA5設為輸出沒反應
新會員
Joined
: 2019/12/17 8:40最後登入時間
: 2021/5/24 10:18
Group:
註冊會員
Level : 2
HP : 0 / 28
MP : 3 / 353
EXP : 12
請教版大及各路高手,我用的IC是PIC16F18325,使用MPLAB X IDE V5.45及PICKIT4進行燒錄,預計將RA1及RA5分別控制2串LED,但只有RA1有輸出,RA5直接用示波器量測都沒輸出訊號,code如下,再請幫忙看一下是定義哪邊有遺漏嗎? -------------------------------------------------------------------------------------------------------------------------------------------------------- #include #pragma config RSTOSC = HFINT32 #pragma config WDTE = ON #pragma config PWRTE = ON #pragma config CP = OFF #pragma config BOREN = OFF #pragma config LVP = OFF #pragma config MCLRE = OFF #define LED_B RA1 #define RH_LED_B RA5 volatile unsigned int milliseconds = 0; void system_initial(void) { OSCCON1bits.NOSC = 0b110; OSCFRQbits.HFFRQ = 0b0100; INTCONbits.GIE = 1; INTCONbits.PEIE = 1; PMD2bits.ADCMD = 1; TRISA = 0b00001100; ANSELA = 0b00000000; WDTCON = 0b00000011; LED_B=0; RH_LED_B=0; } void TIMER2_Init(void) { PR2 = 0b01111101; T2CONbits.T2CKPS = 0b10; T2CONbits.T2OUTPS = 0b0000; T2CONbits.TMR2ON = 1; PIE1bits.TMR2IE = 1; PIR1bits.TMR2IF = 0; } void __interrupt() SystemISR(void) { while(!TMR2IF&&!TMR2IE); TMR2IF = 0; milliseconds++; } int main(void) { system_initial(); TIMER2_Init(); while(1) { CLRWDT(); if(milliseconds==50) { LED_B=1; RH_LED_B=1; } if(milliseconds==100) { LED_B=0; RH_LED_B=0; milliseconds=0; } } }
發表於: 2021/3/5 11:09
You can view topic.
你 不可以 發起新主題
You cannot reply to posts.
You cannot edit your posts.
You cannot delete your posts.
You cannot add new polls.
You cannot vote in polls.
You cannot attach files to posts.
You cannot post without approval.
You cannot use topic type.
You cannot use HTML syntax.
You cannot use signature.
You cannot create PDF files.
You cannot get print page.