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


Browsing this Thread:   1 Anonymous Users






訪客
Early Interrupt的問題
#1
最近在研究dspic33CK系列的ADC專章的early interrupt,看完說明與專章的範例(example 5.5)之後仍不太瞭解

Early interrupt是在conversion ready之前就進入ADC ISR,而在範例裡面又ISR裡面直接讀取ADC buffer。但當下應該還沒conversion ready,請問這樣讀取會得到即時的ADC數值嗎?

以下是專章example
// These variables will keep the conversion result.
volatile unsigned short dataAN0// dedicated core
volatile unsigned short dataAN2// shared core
int main()
{
// ADC INITIALIZATION
// Configure the I/O pins to be used as analog inputs.
ANSELAbits.ANSA0 1TRISAbits.TRISA0 1// AN0/RA0 connected the dedicated core 0
ANSELAbits.ANSA2 1TRISAbits.TRISA2 1// AN2/RA2 connected the shared core
// Configure the common ADC clock.
ADCON3Hbits.CLKSEL 2// clock from FRC oscillator
ADCON3Hbits.CLKDIV 0// no clock divider (1:1)
// Configure the cores’ ADC clock.
ADCORE0Hbits.ADCS 0// dedicated core clock divider (1:2)
ADCON2Lbits.SHRADCS 0// shared core clock divider (1:2)
// Configure sample time for shared core.
ADCON2Hbits.SHRSAMC 10// 12 TAD sample time
// Configure the ADC reference sources.
ADCON3Lbits.REFSEL 0// AVdd as voltage reference
// Configure the integer of fractional output format.
ADCON1Hbits.FORM 0// integer format
// Select single-ended input configuration and unsigned output format.
ADMOD0Lbits.SIGN0 0// AN0/RA0
ADMOD0Lbits.DIFF0 0// AN0/RA0
ADMOD0Lbits.SIGN2 0// AN2/RA2
// Enable and calibrate the module.
EnableAndCalibrate(); // See Example 5-1
// Configure and enable early ADC interrupts.
ADCORE0Hbits.EISEL 0// early interrupt is generated 1 TADCORE clock prior
// to when the data is ready
ADCORE1Hbits.EISEL 3// early interrupt is generated 4 TADCORE clocks prior
// to when the data is ready
ADCON2Lbits.EIEN 1// enable early interrupts for ALL inputs
ADEIELbits.EIEN0 1// enable interrupt for AN0
ADEIELbits.EIEN2 1// enable interrupt for AN2
_ADCAN0IF 0// clear interrupt flag for AN0
_ADCAN0IE 1// enable interrupt for AN0
_ADCAN2IF 0// clear interrupt flag for AN2
_ADCAN2IE 1// enable interrupt for AN2
// Set same trigger source for all inputs to sample signals simultaneously.
ADTRIG0Lbits.TRGSRC0 13// timer 2 for AN0
ADTRIG0Hbits.TRGSRC2 13// timer 2 for AN2
// TIMER 2 INITIALIZATION (TIMER IS USED AS A TRIGGER SOURCE FOR ALL CHANNELS).
T2CONbits.TCS 0// clock from peripheral clock
T2CONbits.TCKPS 0// 1:1 prescale
PR2 0x8000// rollover every 0x8000 clocks
T2CONbits.TON 1// start timer to generate ADC triggers
while(1);
return 
1;
}
// ADC AN0 ISR (DEDICATED CORE)
void __attribute__((interruptno_auto_psv)) _ADCAN0Interrupt(void)
{
dataAN0 ADCBUF0// read conversion result
_ADCAN0IF 0// clear interrupt flag
}
// ADC AN2 ISR (SHARED CORE)
void __attribute__((interruptno_auto_psv)) _ADCAN2Interrupt(void)
{
dataAN2 ADCBUF2// read conversion result
_ADCAN2IF 0// clear interrupt flag
}

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


Re: Early Interrupt的問題
#2
管理員
管理員


查看用戶資訊
這個概念其實就是賺時間差而已, 目的是在進一步縮短中斷響應時間.
在短短的幾個Clock間, 讓ADC的中斷先偷跑, 由於進中斷也需要時間.

進中斷的時間跟ADC轉換同時進行, 前提是時間要抓好, 跑太快資料就錯了.

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


訪客
Re: Early Interrupt的問題
#3
謝謝你的回答,這樣我瞭解了

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... ]

教育訓練中心

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