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


Browsing this Thread:   1 Anonymous Users






Re: Dspic33FJ64MC508A Timer1設定問題
#6
版主
版主


查看用戶資訊
時勢所趨,較舊的元件沒有 MCC的支援,建議換一個較新的 dsPIC33CK256MP506 系列來玩玩。有 APP041 的實驗板可以配合 CAE 空中教室的 PIC1101 的教學課程。

http://www.microchip.com.tw/modules/t ... p?ncsn=2&nsn=41#PageTab11

PIC1001課程, 為基於學習 MCC(MPLAB Code Configurator)程式庫產生器 而開發, 課程中採用 APP041 實驗板, 並引入 PIM模組子板 概念,使用者可以透過購買不同的PIM模組子板, 來更換所需的MCU 8/16/32-bit 微控制器.

APP041實驗板出廠已配置了 PIC24FJ128GB106 16-bit MCU, 而本課程會再搭配 dsPIC33CK256MP506 (APP041-3 PIM模組子板) 來上課, 為學習如何使用 MCC程式庫產生器, 提供了一個基礎且紮實的入門課程.

發表於: 2021/7/9 14:36
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: Dspic33FJ64MC508A Timer1設定問題
#5
初級會員
初級會員


查看用戶資訊
這邊大致上了解。

不過版主提到的用MCC去做設定,但是我剛剛看MCC支援列表,好像沒有支援dsPIC33FJ64MC508A這顆MCU

發表於: 2021/7/9 11:30
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: Dspic33FJ64MC508A Timer1設定問題
#4
版主
版主


查看用戶資訊
1. 使用外部石英晶體震盪期輸入的頻率範圍是1.6 ~ 16MHz. 最高 Fosc 輸出頻率為 80Mhz. 參考地下例子。
建議使用 MCC 來建立系統的設定及周邊函數庫。

// Configure Oscillator to operate the device at 80Mhz

// Fosc= Fin*M / (N1*N2), Fcy=Fosc/2
// Fosc= 8MHz *40 / (2*2) =80 Mhz for 8MHz input clock
    
PLLFBD=38;                // M=40, PLLFBD= M - 2 = 38
    
CLKDIVbits.PLLPOST=0;        // N1=2
    
CLKDIVbits.PLLPRE=0;        // N2=2
    
OSCTUN=0;                // Tune FRC oscillator, if FRC is used

// Disable Watch Dog Timer
    
RCONbits.SWDTEN=0;

// Wait for PLL to lock
//    while(OSCCONbits.LOCK!=1) {};


2. dsPIC33FJ 系列沒有 Reference Frequency 的輸出腳位。所以只能透過 I/O 在 while( ) 回圈內 Toggle 運算用示波器量一下 I/O 輸出的頻率。
3. 使用 Timer 的 I/O Toggle 的測量

有一點很重要的就是要先確定 Fosc 的頻率是你需要的。

發表於: 2021/7/6 12:19
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: Dspic33FJ64MC508A Timer1設定問題
#3
初級會員
初級會員


查看用戶資訊
這邊已經找到問題,CLKDIVbits.PLLPRE設錯,之前設定備註是除4,應該將這個設為CLKDIVbits.PLLPRE = 0b00010才對

發表於: 2021/7/6 9:58
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: Dspic33FJ64MC508A Timer1設定問題
#2
初級會員
初級會員


查看用戶資訊
可以順便問一下,當震盪器設定好之後,有方法可以驗證自己的震盪器設定的結果嗎?

發表於: 2021/7/6 9:22
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Dspic33FJ64MC508A Timer1設定問題
#1
初級會員
初級會員


查看用戶資訊
想請問一下目前是在外部接一顆20Mhz的震盪器,但是目前設定Timer1為10us觸發一次中斷,
進中斷讓I/O腳一直反向動作的時間為500ms,但是出來的時間為3.5秒,是否是我哪邊設定有問題呢?

----------------------OSC設定----------------------
設定圖檔連結
https://imgur.com/saWEPft


/* Disable Watch Dog Timer */
RCONbits.SWDTEN = 0;
//-----OSCCON 震盪器控制暫存器-----//
OSCCONbits.COSC = 0b011; //目前震盪器選擇 0b011 = XTPLL, HSPLL, ECPLL
OSCCONbits.NOSC = 0b011; //新震盪器選擇 0b011 = XTPLL, HSPLL, ECPLL
OSCCONbits.CLKLOCK = 1; //PLL鎖定選擇
//OSCCONbits.LOCK = 0; //PLL鎖定狀態 這個暫存器只能讀取
OSCCONbits.CF = 0; //震盪器故障檢測
OSCCONbits.LPOSCEN = 1; //輔助(LP)震盪器 ON/OFF
OSCCONbits.OSWEN = 0; //震盪器切換 ON/OFF
//-----CLKDIV 震盪器除頻設定暫存器-----//
CLKDIVbits.ROI = 0; //中斷恢復
CLKDIVbits.DOZE = 0b010; //MCU除頻選擇
CLKDIVbits.DOZEN = 0; //DOZE模式 ON/OFF
CLKDIVbits.FRCDIV = 0b000; //內部快速RC震盪器除頻比
CLKDIVbits.PLLPOST = 0b00; //PLL VCO 輸出除頻比 輸出/2
//-----輸入震盪器 經過以下除頻器需在0.8Mhz~8Mhz之間-----
//當外部震盪器為20Mhz,可由此除頻設為4,將震盪頻率降為5Mhz,可符合設定規範
CLKDIVbits.PLLPRE = 0b01100; //PLL輸入分頻比 輸入/4

//-----PLLFBD PLL 倍頻比暫存器-----//
PLLFBDbits.PLLDIV = 30; //PLL倍頻比 32倍

//-----判斷目前是否設定為帶PLL的主震盪器(XT HS EC)這三種-----//
while(OSCCONbits.COSC != 0b011);
//-----判斷目前PLL是否處於失效情況或是被靜止-----//
while(OSCCONbits.LOCK != 1);

----------------------Timer 1 設定----------------------
設定圖檔連結
https://imgur.com/Wh7aEX2


T1CONbits.TON = 0; //Timer Disable 確認關閉Timer1再進行初始化
T1CONbits.TCS = 0; //Timer 時鐘選擇 1 = 引腳(T1CK)外部時鐘 0 = 內部時鐘(FOSC / 2)
T1CONbits.TGATE = 0; //禁用門控定時器模式
T1CONbits.TCKPS = 0; //Timer 預除器 1:1

TMR1 = 0; //中斷暫存器歸零
PR1 = 400 - 1; //40,000,000 hz / 100,000 hz = 400 (10uS 觸發一次)

IPC0bits.T1IP=7; //設定中斷優先等級 7 = 最高
IFS0bits.T1IF = 0; //將Timer 1 中斷旗標歸零
IEC0bits.T1IE=1; //中斷允許功能 開啟

// T1CONbits.TSIDL = 0; //空閒模式繼續工作
// T1CONbits.TSYNC = 0; //Timer 外部時鐘輸入同步選擇 TCS為0時忽略

T1CONbits.TON = 1; //Timer Enable 啟動Timer1

----------------------Timer 1 中斷----------------------
void __attribute__((interrupt,auto_psv)) _T1Interrupt(void)
{
Toggle_cnt++;
if(Toggle_cnt >= 50000)
{
BRAKE_O = !BRAKE_O;
Toggle_cnt = 0;
}
}

發表於: 2021/7/5 15:04
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... ]

教育訓練中心

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