• slider image 514
  • slider image 516
  • slider image 517
  • slider image 518
  • slider image 519
:::


Browsing this Thread:   2 Anonymous Users






Re: 我寫的TLC2543的驅動程序
#2
新會員
新會員


查看用戶資訊
可能是晶振的問題。板子外接10MHz晶體振盪器,TLC2543時鐘要求4MHz。這該如何實現,在程序裏延時可以麽?

發表於: 2007/4/26 18:36
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


我寫的TLC2543的驅動程序
#1
新會員
新會員


查看用戶資訊
#define io_clk PORTAbits.RA0
#define io_clk_dir TRISAbits.TRISA0
#define ad_data_in PORTAbits.RA1
#define ad_data_in_dir TRISAbits.TRISA1

#define ad_data_out PORTAbits.RA2
#define ad_data_out_dir TRISAbits.TRISA2
#define ad_cs PORTAbits.RA3
#define ad_cs_dir TRISAbits.TRISA3
#define ad_eoc PORTAbits.RA4
#define ad_eoc_dir TRISAbits.TRISA4

#define port_out 0
#define port_in 1

void ad_setup();
unsigned int ad_setgetchannel(unsigned char channel);

unsigned int ad_data;

void main(void)
{
ad_setup();
while(1)
{
ad_data = ad_setgetchannel(0);
Nop();
Nop();
}
}

//call this once to set it up
void ad_setup()
{

ad_data_in_dir = port_out;
ad_data_out_dir = port_in;

io_clk_dir = port_out;
ad_cs_dir = port_out;
ad_eoc = port_in;
ad_cs = 1;
}

unsigned int ad_setgetchannel(unsigned char channel)
{
signed char i;
unsigned int data = 0x0;
unsigned int ch_config;

i=0;
do
{} while( ad_eoc == 0);


io_clk = 0;
ad_cs = 0;
/
for (i=0;i<12;i++)
{
data <<=1;
data |=ad_data_out;

if (channel&=0x80) ad_data_in =1;
else ad_data_in = 0;

io_clk=1;
channel <<= 1;
io_clk=0;
}
ad_cs = 1;
return data;
}

請幫我看下有什麽問題麽?在watch窗口裏看到ad_data值總是零。我用的18f452。spi接口另有用処所以用軟件模擬了spi。

發表於: 2007/4/26 16:52
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... ]

教育訓練中心

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