版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、/ main函数#include DSP2833x_Device.h / DSP2833x Headerfile Include File#include DSP2833x_Examples.h / DSP2833x Examples Include File#include sci.h#define NUM 10/ Prototype statements for functions found within this file.void SCI_Operation();void SCIA_Operation(void);void SCIB_Operation(void);void SCIC
2、_Operation(void);void sci_config_init(void);void scia_config_init(void);void scib_config_init(void);void scic_config_init(void);void SCI_FIFO_Init(void);void SCIA_FIFO_Init(void);void SCIB_FIFO_Init(void);void SCIC_FIFO_Init(void);void SCIA_Character_Send_Msg(char character);void SCIB_Character_Send
3、_Msg(char character);void SCIC_Character_Send_Msg(char character);void SCI_Send_Msg(char *message);void SCI_Send_Msg_Count(char count,char *message);char SCI_Receive_Buff();char SCIA_Receive_Buff(void);char SCIB_Receive_Buff(void);char SCIC_Receive_Buff(void);char *msg=rnHello Yan Xu!0;char *message
4、1= rnlearner the scic!0;char ReceivedChar;char LoopCount =0;void main(void) InitSysCtrl(); Init_SCI_Gpio(); InitXintf16Gpio(); DINT; InitPieCtrl(); IER = 0x0000; IFR = 0x0000; InitPieVectTable(); SCI_FIFO_Init(); / Initialize the SCI FIFO sci_config_init(); / Initalize SCI for echoback SCI_Send_Msg(
5、msg); SCI_Send_Msg_Count(NUM,message1); msg = rnYou will enter a character, and the DSP will echo it back! n0; SCI_Send_Msg(msg); while(LoopCount+10) SCI_Operation(); void SCI_Operation()#if (DSP2833x_SCI_A) SCIA_Operation();#endif#if (DSP2833x_SCI_B) SCIB_Operation();#endif#if (DSP2833x_SCI_C) SCIC
6、_Operation();#endifvoid SCIA_Operation(void) msg = rnEnter a character: 0; SCI_Send_Msg(msg); ReceivedChar = SCIA_Receive_Buff(); / Echo character back msg = You sent: 0; SCI_Send_Msg(msg); SCIA_Character_Send_Msg(ReceivedChar);void SCIB_Operation(void) msg = rnEnter a character: 0; SCI_Send_Msg(msg
7、); ReceivedChar = SCIB_Receive_Buff(); / Echo character back msg = You sent: 0; SCI_Send_Msg(msg); SCIB_Character_Send_Msg(ReceivedChar);void SCIC_Operation(void) msg = rnEnter a character: 0; SCI_Send_Msg(msg); ReceivedChar = SCIC_Receive_Buff(); / Echo character back msg = You sent: 0; SCI_Send_Ms
8、g(msg); SCIC_Character_Send_Msg(ReceivedChar);void sci_config_init(void)#if (DSP2833x_SCI_A)/ Test 1,SCIA DLB, 8-bit word, baud rate 0x000F, default, 1 STOP bit, no parityscia_config_init();#endif#if (DSP2833x_SCI_B)/ Test 1,SCIA DLB, 8-bit word, baud rate 0x000F, default, 1 STOP bit, no parityscib_
9、config_init();#endif#if (DSP2833x_SCI_C)/ Test 1,SCIA DLB, 8-bit word, baud rate 0x000F, default, 1 STOP bit, no parity scic_config_init();#endif/ Test 1,SCIA DLB, 8-bit word, baud rate 0x000F, default, 1 STOP bit, no parityvoid scia_config_init() / Note: Clocks were turned on to the SCIA peripheral
10、 / in the InitSysCtrl() function SciaRegs.SCICCR.all =0x0007; / 1 stop bit, No loopback / No parity,8 char bits, / async mode, idle-line protocolSciaRegs.SCICTL1.all =0x0003; / enable TX, RX, internal SCICLK, / Disable RX ERR, SLEEP, TXWAKESciaRegs.SCICTL2.all =0x0003;SciaRegs.SCICTL2.bit.TXINTENA =
11、 1;SciaRegs.SCICTL2.bit.RXBKINTENA =1;#if (CPU_FRQ_150MHZ) SciaRegs.SCIHBAUD =0x0001; / 9600 baud LSPCLK = 37.5MHz. SciaRegs.SCILBAUD =0x00E7;#endif#if (CPU_FRQ_100MHZ) SciaRegs.SCIHBAUD =0x0001; / 9600 baud LSPCLK = 20MHz. SciaRegs.SCILBAUD =0x0044;#endifSciaRegs.SCICTL1.all =0x0023; / Relinquish S
12、CI from Reset/ Test 1,SCIA DLB, 8-bit word, baud rate 0x000F, default, 1 STOP bit, no parityvoid scib_config_init() / Note: Clocks were turned on to the SCIA peripheral / in the InitSysCtrl() functionScibRegs.SCICCR.all =0x0007; / 1 stop bit, No loopback / No parity,8 char bits, / async mode, idle-l
13、ine protocolScibRegs.SCICTL1.all =0x0003; / enable TX, RX, internal SCICLK, / Disable RX ERR, SLEEP, TXWAKEScibRegs.SCICTL2.all =0x0003;ScibRegs.SCICTL2.bit.TXINTENA = 1;ScibRegs.SCICTL2.bit.RXBKINTENA =1;#if (CPU_FRQ_150MHZ) ScibRegs.SCIHBAUD =0x0001; / 9600 baud LSPCLK = 37.5MHz. ScibRegs.SCILBAUD
14、 =0x00E7;#endif#if (CPU_FRQ_100MHZ) ScibRegs.SCIHBAUD =0x0001; / 9600 baud LSPCLK = 20MHz. ScibRegs.SCILBAUD =0x0044;#endifScibRegs.SCICTL1.all =0x0023; / Relinquish SCI from Reset/ Test 1,SCIA DLB, 8-bit word, baud rate 0x000F, default, 1 STOP bit, no parityvoid scic_config_init() / Note: Clocks we
15、re turned on to the SCIA peripheral / in the InitSysCtrl() function ScicRegs.SCICCR.all =0x0007; / 1 stop bit, No loopback / No parity,8 char bits, / async mode, idle-line protocolScicRegs.SCICTL1.all =0x0003; / enable TX, RX, internal SCICLK, / Disable RX ERR, SLEEP, TXWAKEScicRegs.SCICTL2.all =0x0
16、003;ScicRegs.SCICTL2.bit.TXINTENA = 1;ScicRegs.SCICTL2.bit.RXBKINTENA =1;#if (CPU_FRQ_150MHZ) ScicRegs.SCIHBAUD =0x0001; / 9600 baud LSPCLK = 37.5MHz. ScicRegs.SCILBAUD =0x00E7;#endif#if (CPU_FRQ_100MHZ) ScicRegs.SCIHBAUD =0x0001; / 9600 baud LSPCLK = 20MHz. ScicRegs.SCILBAUD =0x0044;#endifScicRegs.
17、SCICTL1.all =0x0023; / Relinquish SCI from Reset/ Transmit a character from the SCIvoid SCIA_Character_Send_Msg(char character)while(SciaRegs.SCICTL2.bit.TXRDY=0)SciaRegs.SCITXBUF=character;void SCIB_Character_Send_Msg(char character)while(ScibRegs.SCICTL2.bit.TXRDY=0)ScibRegs.SCITXBUF=character;voi
18、d SCIC_Character_Send_Msg(char character)while(ScicRegs.SCICTL2.bit.TXRDY=0)ScicRegs.SCITXBUF=character;void SCI_FIFO_Init()#if (DSP2833x_SCI_A)SCIA_FIFO_Init();#endif#if (DSP2833x_SCI_B)SCIB_FIFO_Init();#endif#if (DSP2833x_SCI_C)SCIC_FIFO_Init();#endif/ Initalize the SCI FIFOvoid SCIA_FIFO_Init() S
19、ciaRegs.SCIFFTX.all=0x8000;/ Initalize the SCI FIFOvoid SCIB_FIFO_Init() ScibRegs.SCIFFTX.all=0x8000;/ Initalize the SCI FIFOvoid SCIC_FIFO_Init() ScicRegs.SCIFFTX.all=0x8000;/ ScicRegs.SCIFFRX.all=0x204f;/ ScicRegs.SCIFFCT.all=0x0;char SCI_Receive_Buff()#if (DSP2833x_SCI_A)return( SCIA_Receive_Buff
20、();#endif#if (DSP2833x_SCI_B)return (SCIB_Receive_Buff();#endif#if (DSP2833x_SCI_C)return (SCIC_Receive_Buff();#endifchar SCIA_Receive_Buff() / Wait for inc character while(SciaRegs.SCIRXST.bit.RXRDY !=1) / wait for XRDY =1 for empty state / Get character return SciaRegs.SCIRXBUF.all;char SCIB_Recei
21、ve_Buff() / Wait for inc character while(ScibRegs.SCIRXST.bit.RXRDY !=1) / wait for XRDY =1 for empty state / Get character return ScibRegs.SCIRXBUF.all;char SCIC_Receive_Buff() / Wait for inc character while(ScicRegs.SCIRXST.bit.RXRDY !=1) / wait for XRDY =1 for empty state / Get character return S
22、cicRegs.SCIRXBUF.all;void SCI_Send_Msg(char *message)int i=0;while(messagei+!=0)#if(DSP2833x_SCI_A)SCIA_Character_Send_Msg(messagei);#endif#if(DSP2833x_SCI_B)SCIB_Character_Send_Msg(messagei);#endif#if(DSP2833x_SCI_C)SCIC_Character_Send_Msg(messagei);#endifvoid SCI_Send_Msg_Count(char count,char *me
23、ssage)while(count-)SCI_Send_Msg(message);/=/ No more./=/=/ sci.c文件/=#include DSP2833x_Device.h / DSP2833x Headerfile Include File#include DSP2833x_Examples.h / DSP2833x Examples Include File#include sci.hvoid Init_SCI_Gpio()#if DSP2833x_SCI_A InitSCIAGpio();#endif#if DSP2833x_SCI_B InitSCIBGpio();#e
24、ndif#if DSP2833x_SCI_CInitSCICGpio();#endifvoid InitSCIAGpio(void) EALLOW; /ENBALE PULL-UP FUNCTION GpioCtrlRegs.GPBPUD.bit.GPIO36 = 0; / Enable pull-up for GPIO28 (SCIRXDA) GpioCtrlRegs.GPBPUD.bit.GPIO35 = 0; / Enable pull-up for GPIO29 (SCITXDA) GpioCtrlRegs.GPBQSEL1.bit.GPIO35 = 3; / Asynch input
25、 GPIO28 (SCIRXDA) GpioCtrlRegs.GPBQSEL1.bit.GPIO36 = 3; GpioCtrlRegs.GPBMUX1.bit.GPIO36 = 1; / Configure GPIO28 for SCIRXDA operation GpioCtrlRegs.GPBMUX1.bit.GPIO35 = 1; / Configure GPIO29 for SCITXDA operation#if 0GpioCtrlRegs.GPAPUD.bit.GPIO28 = 0; / Enable pull-up for GPIO28 (SCIRXDA)GpioCtrlReg
26、s.GPAPUD.bit.GPIO29 = 0; / Enable pull-up for GPIO29 (SCITXDA)GpioCtrlRegs.GPAQSEL2.bit.GPIO28 = 3; / Asynch input GPIO28 (SCIRXDA)GpioCtrlRegs.GPAMUX2.bit.GPIO28 = 1; / Configure GPIO28 for SCIRXDA operationGpioCtrlRegs.GPAMUX2.bit.GPIO29 = 1; / Configure GPIO29 for SCITXDA operation#endifEDIS;void
27、 InitSCIBGpio() EALLOW;/* Enable internal pull-up for the selected pins */ Pull-ups can be enabled or disabled disabled by the user./ This will enable the pullups for the specified pins./ Comment out other unwanted lines./ GpioCtrlRegs.GPAPUD.bit.GPIO9 = 0; / Enable pull-up for GPIO9 (SCITXDB) GpioC
28、trlRegs.GPAPUD.bit.GPIO14 = 0; / Enable pull-up for GPIO14 (SCITXDB) /GpioCtrlRegs.GPAPUD.bit.GPIO18 = 0; / Enable pull-up for GPIO18 (SCITXDB)/ GpioCtrlRegs.GPAPUD.bit.GPIO22 = 0; / Enable pull-up for GPIO22 (SCITXDB)/ GpioCtrlRegs.GPAPUD.bit.GPIO11 = 0; / Enable pull-up for GPIO11 (SCIRXDB) GpioCt
29、rlRegs.GPAPUD.bit.GPIO15 = 0; / Enable pull-up for GPIO15 (SCIRXDB) / GpioCtrlRegs.GPAPUD.bit.GPIO19 = 0; / Enable pull-up for GPIO19 (SCIRXDB)/ GpioCtrlRegs.GPAPUD.bit.GPIO23 = 0; / Enable pull-up for GPIO23 (SCIRXDB)/* Set qualification for selected pins to asynch only */ This will select asynch (
30、no qualification) for the selected pins./ Comment out other unwanted lines./ GpioCtrlRegs.GPAQSEL1.bit.GPIO11 = 3; / Asynch input GPIO11 (SCIRXDB) GpioCtrlRegs.GPAQSEL1.bit.GPIO15 = 3; / Asynch input GPIO15 (SCIRXDB) /GpioCtrlRegs.GPAQSEL2.bit.GPIO19 = 3; / Asynch input GPIO19 (SCIRXDB)/ GpioCtrlReg
31、s.GPAQSEL2.bit.GPIO23 = 3; / Asynch input GPIO23 (SCIRXDB)/* Configure SCI-B pins using GPIO regs*/ This specifies which of the possible GPIO pins will be SCI functional pins./ Comment out other unwanted lines./ GpioCtrlRegs.GPAMUX1.bit.GPIO9 = 2; / Configure GPIO9 for SCITXDB operation GpioCtrlRegs
32、.GPAMUX1.bit.GPIO14 = 2; / Configure GPIO14 for SCITXDB operation /GpioCtrlRegs.GPAMUX2.bit.GPIO18 = 2; / Configure GPIO18 for SCITXDB operation/ GpioCtrlRegs.GPAMUX2.bit.GPIO22 = 3; / Configure GPIO22 for SCITXDB operation/ GpioCtrlRegs.GPAMUX1.bit.GPIO11 = 2; / Configure GPIO11 for SCIRXDB operation GpioCtrlRegs.GPAMUX1.bit.GPIO15 = 2; / Configure GPIO15 for SCIRXDB operation / GpioCtrlRegs.GPAMUX2.bit.GPIO19 = 2; / Configure GPIO19 for SCIRXDB operation/ GpioCtrlRegs.GPAMUX2.bit.GPIO23 = 3; / Configure GPIO23 f
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 儿童书画学校转让合同
- 2024年度软件开发合同标的及服务内容2篇
- 驾校学员培训合同范例
- 2024全新艺术品典押与抵押合同范本下载3篇
- 门头房租金合同范例
- 资产委托合同范例
- 2024停车场绿色节能技术与委托管理服务协议3篇
- 驾校定修车合同范例
- 2024年度内陆地区水利枢纽工程承包合同3篇
- 网吧供货合同范例
- 冀少版小学六年级音乐上册教案
- 江苏省人民医院改建一台γ刀放射治疗项目环评报告
- 研究开发费用自查报告
- 国有土地上房屋装修备案申请表
- 放射医学(副高)高级职称试题库及答案
- 职业暴露处理记录表
- 电大信息技术应用终结性作业
- GB/T 9115-2010对焊钢制管法兰
- GB/T 20721-2006自动导引车通用技术条件
- GB/T 15256-2014硫化橡胶或热塑性橡胶低温脆性的测定(多试样法)
- 皖医大内科学习题及答案
评论
0/150
提交评论