1945 views|0 replies

2015

Posts

0

Resources
The OP
 

About DSP28335 SPI transmission [Copy link]

#include "DSP2833x_Device.h"
#include "DSP2833x_Examples.h"
unsigned char table[]={

0xC0, //"0"
0xF9, //"1"
0xA4, //"2"
0xB0, //"3"
0x99, //"4"
0x92, //"5"
0x82, //"6"
0xF8, //"7"
0x80, //"8"
0x90, //"9"
0x88, //"A"
0x83, //"B"
0xC6, //"C"
0xA1, //"D"
0x86, //"E"
0x8E, //"F"
0x89, //"H"
0xC7, //"L"
0xC8, //"n"
0xC1, //"u"
0x8C, //"P"
0xA3, //"o"
0xBF, //"-"
0xFF, //熄灭
0xFF //自定义

};

void init(void)
{
InitSysCtrl();
InitSpiaGpio();
EALLOW;
GpioCtrlRegs.GPBMUX2.bit.GPIO58=0;
GpioCtrlRegs.GPBDIR.bit.GPIO58=1;
GpioCtrlRegs.GPBMUX2.bit.GPIO59=0;
GpioCtrlRegs.GPBDIR.bit.GPIO59=1;
GpioCtrlRegs.GPBMUX2.bit.GPIO63=0;
GpioCtrlRegs.GPBDIR.bit.GPIO63=1;
GpioCtrlRegs.GPBMUX2.bit.GPIO62=0;
GpioCtrlRegs.GPBDIR.bit.GPIO62=1;
EDIS;
GpioDataRegs.GPBSET.bit.GPIO58=1;
GpioDataRegs.GPBSET.bit.GPIO59=0;
GpioDataRegs.GPBSET.bit.GPIO62=0;
GpioDataRegs.GPBSET.bit.GPIO63=1;
}

void delay(void)
{
long int i,j;
for(i=0;i<1000;i++)
for(j=0;j<10000;j++);
}

void delay1(void)
{
long int i,j;
for(i=0;i<10;i++)
for(j=0;j<10;j++);
}
void init_spi(void)
{
SpiaRegs.SPICCR.bit.CLKPOLARITY=1;

SpiaRegs.SPICTL.bit.TALK=1;//发送启动
SpiaRegs.SPICTL.bit.CLK_PHASE=0;
SpiaRegs.SPICTL.bit.MASTER_SLAVE=1;
SpiaRegs.SPICCR.bit.SPICHAR=0x0f;
SpiaRegs.SPIBRR =0x007F;
SpiaRegs.SPICCR.bit.SPISWRESET=1;
SpiaRegs.SPIPRI.bit.FREE=1;
}
void main(void)
{
int k;
init();
init_spi();
while(1)
{
for(k=0;k<16;k++)
{
if(SpiaRegs.SPISTS.bit.BUFFULL_FLAG!=1)
{
SpiaRegs.SPITXBUF=table[k];
delay();
// delay();
}
// delay();
}
}
}

This post is from DSP and ARM Processors
 

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list