• slider image 442
  • slider image 477
  • slider image 479
  • slider image 480
  • slider image 481
  • slider image 482
:::


Browsing this Thread:   1 Anonymous Users






訪客
PIC16F1824使用timer1內部時間震盪的問題
#1
各位前輩好,想跟前輩詢問,目前使用開發版APP026-3、PIC16F1824、MPLAB X IDE v3.35、C18,時間程式寫完都會無法燒入會出現
->error: (141) can't open include file "timers.h": No such file or directory

看完DATA也不太了解為甚麼會出現!

有看到DATA說用內部時鐘源2 LSB讀取Timer1時會出現分辨率錯誤值。

要用異步源,我選擇T1G引腳上與Timer1異步事件門,所以我用線把T1CKI和T1G有連接起來。

麻煩請各位前輩請教。


程式以下:
#include <pic16f1824.h>
#include<timers.h>
#include<math.h>
#include<delays.h>

#pragma config FOSC =HSMP
#pragma config PLLCFG = OFF
#pragma config XINST = OFF
#pragma config WDTEN = OFF

void time_1(void);

#pragma code time1=0x18 //high interrupt
void time1 (void)
{
_asm GOTO time_1 _endasm
}
#pragma code

#pragma interrupt time_1

void time_1(void)
{
PIR1bits.TMR1IF=0;
WriteTimer1(0);
TR=1;
}

void main ()
{
Delay10KTCYx(10);

PIE1bits.TMR1IE = 1; //中斷
INTCONbits.GIE = 1; //開啟全域中斷功能
INTCONbits.PEIE = 1; //開啟周邊中斷功能


T1CON = 0b01101001;
T1GCON = 0b00000100;


WriteTimer1(0); //time1
PIR1bits.TMR1IF = 0; //清除中斷旗標
}

Attach file:



jpg  (0.00 KB)


Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: PIC16F1824使用timer1內部時間震盪的問題
#2
管理員
管理員


查看用戶資訊
沒猜錯的話, 應該是Comipler版本問題, XC8在v1.34版後, 架構上有些重大變化. 舊的專案可能無法直接使用. 建議改用XC8 v1.34版本試試看...

發表於: 2020/5/22 10:39
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


訪客
Re: PIC16F1824使用timer1內部時間震盪的問題
#3
感謝您提供的訊息,我會再去試看看,再次感謝

Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


訪客
Re: PIC16F1824使用timer1內部時間震盪的問題
#4
剛剛使用XC8在v1.34版、XC8在v1.37版、XC8在v2.20版,還是一樣問題。
會是我的時間標頭檔在這PIC16F1824沒有嗎,如果刪掉時間它又會顯示include<delays.h>->error: (141) can't open include file "timers.h": No such file or directory,本身也需要ADC轉換,標頭檔#include<adc.h>也是一樣問題

Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: PIC16F1824使用timer1內部時間震盪的問題
#5
版主
版主


查看用戶資訊
1. 你的一篇貼文的程式是用 C18 的語法寫的,C18 不支援 PIC16F1824 的元件,所以是編譯不會過的。現在 PIC16Fxxx & PIC18Fxxx 都使用新的編譯器 XC8 了。

2. delay.h 所支援的函數是屬於舊版的 XC 8 compiler 在 v1.34 及C18 才有的 Library,XC8 在 v1.34 的版本就不再支援周邊函數庫,改由 MCC 依你實際的需要設定後來產生周邊函數庫的。所以你程式所列的這些周邊函數在現有的 XC8 下是找不到這些這些函數的支援。

3. 如果你不用 MCC 來產生周邊函數庫的話,除 math.h 外其他的都要自己寫了。

4. 關於MCC 的使用,初階可以參考 PIC101 X IDE & MCC & XC8 基礎課程 的教材,進階 MCC 使用可以參考 CIP102v2.00 進階獨立式週邊(Adv. CIP)的應用 教材。
以上的教材都可以載教育訓練光碟下找到。
http://www.microchip.com.tw/Data_CD/

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


訪客
Re: PIC16F1824使用timer1內部時間震盪的問題
#6
感謝版主,謝謝協助

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連結

https://www.facebook.com/microchiptechnologytaiwan/
http://www.microchip.com.tw/modules/tad_uploader/index.php?of_cat_sn=13
https://mu.microchip.com/page/tmu
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/modules/tad_uploader/index.php?of_cat_sn=2
http://www.microchip.com.tw/Data_CD/eLearning/index.html
http://www.microchip.com.tw/RTC/RTC_DVD/
https://www.microchip.com/development-tools/
https://www.youtube.com/user/MicrochipTechnology
[ more... ]

教育訓練中心

!開發工具購買
辦法說明 [業界客戶] [教育單位]
----------------------------------
!校園樣品申請
辦法說明 [教師資格] [學生資格]
----------------------------------