• slider image 442
  • slider image 483
  • slider image 484
  • slider image 485
  • slider image 486
  • slider image 487
:::


Browsing this Thread:   1 Anonymous Users






Re: A/D轉換問題
#2
版主
版主


查看用戶資訊
如果 "ADCBUF0的值都一直是E1CD " 的話,那代表什麼問題? 很明顯的 ADC 的轉換有問題。
所以先將 ADC 的轉換搞定後再來試驗 PWM 。

http://www.microchip.com.tw/modules/w ... glefile.php?cid=4&lid=229
這裡有 ADC 設定的說明與範例。(dsPIC30F4011)

發表於: 2009/10/8 9:45
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


A/D轉換問題
#1
新會員
新會員


查看用戶資訊
請各位先進幫我看看程式
快瘋了= =
我想寫出一個可輸入0~5V然後改變PWM輸出的程式
可我ad轉換一直出問題
我Tcy=33ns
A/D速度是500ksps
Tad=165ns
取樣時間為1Tad
AN3為輸入
程式如下;

#include <p30f4011.h>
#include <pwm.h>

#define FCY 7372800*2
#define PWM_PTPER 450
//int PWM_PTPER = 450;
#define timerPR1 500

_FOSC(CSW_FSCM_OFF & XT_PLL8); //XT with 8xPLL oscillator, Failsafe clock offIRRtO
_FWDT(WDT_OFF); //Watchdog timer disabledk-
_FBORPOR(PBOR_OFF & MCLR_EN); //Brown-out reset disabled, MCLR reset enabledj{g
_FGS(CODE_PROT_OFF); //Code protect disabledw9w/

int ADCbuff = 1024;
void Init_MCPWM(void);
void initalADC12(void);

void main()
{
initalADC12();
Init_MCPWM();

while(1)
{
while( ADCON1bits.DONE );
ADCON1bits.DONE = 0;
ADCbuff = ADCBUF0;
PDC1 = 2*PTPER*ADCBUF0; //2^10=0x0400
}

return 0;
}

void initalADC12(void)
{
IFS0bits.ADIF = 0;
IEC0bits.ADIE = 0;

ADCON1bits.ADON = 0;
ADPCFG = 0xFFF7;
ADCHS = 0x0003;
ADCON1 = 0x03E4;
ADCON2 = 0x0000;
ADCON3 = 0x0189;
ADCSSL = 0x0000;
ADCON1bits.ADON = 1;
}


可我無論怎麼改輸入電壓
PWM依舊不會變
ADCBUF0的值都一直是E1CD
是不是我程式有哪寫錯@@

發表於: 2009/10/7 15:43
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... ]

教育訓練中心

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