• 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






請問關於使用dspic30f3014內部data memory
#1
新會員
新會員


查看用戶資訊
最近要將A/D完的數值,
存到data memory裡,(約1000筆)
再經由rs232傳到PC,
可是對於如何自行規劃一個memory範圍,
始終不清楚,
我有試著宣告:
unsigned int array1[1000] __attribute__((persistent, aligned(32)));
但是傳出去的筆數,始終不對。
不知道各位大大,可否給我一些指點。
以下是我所寫的程式,
我用過MPLAB SIM模擬結果是對的,
可是燒入到dsPIC後,卻只剩下250筆,
我試了很久還是這樣,
不知道大大們有遇過這樣的問題。
(程式的動作是A/D--->存檔--->rs232傳至電腦)

#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/14 11:47
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... ]

教育訓練中心

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