Blackfin BF533 SPI 調試日誌

來源:互聯網
上載者:User

 原文地址::http://www.cnblogs.com/yanhc/archive/2008/08/22/2175269.html

 

最近參加ADI的UDC(University Design Competition)比賽,調試觸控螢幕,用的是BF533,調試SPI調試了半天,問億旗,只是搪塞回答了一下,後來問中國ADI的DSP支援人員,他們還在開發板上調試了My Code,真負責,原來是我沒有加ssync();這條語句。
不過,現在觸控螢幕還是有問題,BF533不能和它通訊目前。

 

 

//** file: spi.h
//** target: ADSP-BF533
//** creat time: 2008-8-19
#ifndef _SPI_H
#define _SPI_H

#define SPI_SEL_LOW        *pSPI_FLG &= ~0x2000 // SPISEL5 clr
#define SPI_SEL_HIGH    *pSPI_FLG |= 0x2000 // SPISEL5 set

//SPI interface funtion
void SPI_Init(void);

//SPI send a word function
void SPI_send_data(unsigned short data);

//SPI receive a word function
unsigned short SPI_receive_data(void);

#endif

//** file: spi.c
//** target: ADSP-BF533
//** creat time: 2008-8-19
#include <ccblkfn.h>
#include <cdefBF533.h>
#include "sys_func.h"

//SPI interface funtion
void SPI_Init(void)
{
    *pSPI_BAUD = (unsigned short)(GetSCLK() / (2 * 10000000)); // 5MHz
    //SPI enable,master mode,CPHA=1(control by software),
    //16 bit,Start transfer with write of SPI_TDBR
    *pSPI_CTL = 0x5501;
    *pSPI_FLG = 0xFF20; // SPISEL5 enabled
}

//SPI send a word function
void SPI_send_data(unsigned short data)
{
*pSPI_TDBR = data;
while ((*pSPI_STAT & 0x0001) == 0) ;
}

//SPI receive a word function
unsigned short SPI_receive_data(void)
{
    SPI_send_data(0xFFFF);
    return (*pSPI_RDBR);
}

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.