• slider image 276
  • slider image 277
  • slider image 278
  • slider image 279
  • slider image 280
  • slider image 281
:::


Browsing this Thread:   1 Anonymous Users






PIC16F18325 RA5設為輸出沒反應
#1
新會員
新會員


查看用戶資訊
請教版大及各路高手,我用的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;
}
}
}

發表於: 3/5 11:09
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: PIC16F18325 RA5設為輸出沒反應
#2
管理員
管理員


查看用戶資訊
#define LED_B RA1 修正-> #define LED_B LATAbits.LATA1
#define RH_LED_B RA5 修正-> #define RH_LED_B LATAbits.LATA5

發表於: 3/5 17:41
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部







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.

[進階搜尋]


:::

Microchip連結

http://elearning.microchip.com.tw/modules/tad_link/index.php?cate_sn=1
https://page.microchip.com/APAC-PrefCenters-TW.html
http://www.microchip.com/
http://www.microchip.com/treelink
http://www.microchipdirect.com/
http://www.microchip.com.cn/newcommunity/index.php?m=Video&a=index&id=103
http://www.microchip.com.tw/Data_CD/eLearning/index.html
http://www.microchip.com.tw/modules/tad_uploader/index.php?of_cat_sn=2
http://www.microchip.com.tw/RTC/RTC_DVD/
https://www.microchip.com/development-tools/
[ more... ]

Microchip CAE 空中教室

教育訓練中心

課程 - 台北教育訓練中心
課程 - 新竹教育訓練中心
課程 - 高雄教育訓練中心
教育訓練中心介紹
購買 - 實驗工具
臺灣實驗板介紹與資源