DSP

Blackfin BF533 SPI 调试日志

2019-07-13 19:04发布

 原文地址::http://www.cnblogs.com/yanhc/archive/2008/08/22/2175269.html   最近参加ADI的UDC(University Design Competition)比赛,调试触摸屏,用的是BF533,调试SPI调试了半天,问亿旗,只是搪塞回答了一下,后来问中国ADI的DSP技术支持,他们还在开发板上调试了我的代码,真负责,原来是我没有加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
#include
#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);
}