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


Browsing this Thread:   1 Anonymous Users






請問
#1
新會員
新會員


查看用戶資訊
最近再寫一個A/D後存值--->再經由rs232傳到PC,
可是我發現我傳的筆數是陣列值的1/4,之後我有查看一下,
array_index的變數都是一次加四(0,4,8,12.......),
可是我現在一直找不到原因,
不知道大大們,可以給我一些建議嗎??
由於這是我第一次使用dspic所以有很多設定不清楚。
以下是我寫的程式。


#include "p30f3014.h"
#include <stdio.h>

#define counter 1000
unsigned int array_index=0;
unsigned int array1[counter] __attribute__((persistent,aligned(32)));
char flag=0,count=0;

void put(char cc)
{
U1TXREG=cc;

while(!U1STAbits.TRMT)
;

}
void getAD()
{
ADCON1bits.FORM = 0;//0000 dddd dddd dddd
ADCON1bits.SSRC = 7;
ADCON1bits.ASAM = 1;//1自動 0手動
ADCON2bits.VCFG = 0;
ADCON2bits.BUFM = 0;
ADCON3bits.ADRC = 0;
ADCON3bits.SAMC =1;//11 samping時間
ADCON3bits.ADCS =7;//4/7
ADCHSbits.CH0SA =0;
ADCSSL =1;
ADPCFG =0xFFFE;
ADCON1bits.ADON = 1;
///////////////////////////////////////
ADCON1bits.DONE=0;
ADCON1bits.SAMP=1;
while(ADCON1bits.DONE==0)
;
array1[array_index]=ADCBUF0;
array_index=array_index+1;

if(array_index==counter)
{

flag=1;
array_index=0;
}
}
int main(void)
{
TRISD=0xFF00;
LATDbits.LATD0=1;
U1BRG=38;
U1MODE=0x8000;
U1STAbits.UTXEN=1;


while(1)
{

if(flag==0)
getAD(0);
if(flag==1)
{
if(array_index<counter)
{
LATDbits.LATD0=0;
put(array1[array_index]>>8);
put(array1[array_index]);
array_index=array_index+1;
}

else
{
LATDbits.LATD0=1;
flag=2;
}

}

}

}





發表於: 2006/6/16 10:39
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... ]

教育訓練中心

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