📄 main.c
字号:
#include "option.h"
#include "def.h"
#include "44b.h"
#include "44blib.h"
#define BIT_SIO_START 1<<3
void SIO_Init(void)
{
rPDATF=0x1ff; //All is High
rPCONF=0x1B6C00; //configure to SIO function
rPUPF=0x000; // All SIO pins pull up enable
rSIOCON=0x31;// 00110001, internal clock, MSB, transmit/recept, up edge recept, auto run, SIO interrupt mode
rSIODAT=0X00;
rSBRDR=59; //Baud=500KHz,MCLK=60MHz,Baud=MCLK/2/(rSBRDR+1)
rIVTCNT=0;
rDCNTZ=0;
rI_ISPC|=BIT_SIO;//Clear the flag of SIO_INTPND
}
void SendSIOData(unsigned char data)
{
rSIODAT=data;
rSIOCON|=BIT_SIO_START;//Start the operation of transmition
while(!(rINTPND&BIT_SIO));//Wait
rI_ISPC|=BIT_SIO;//Clear the flag of SIO_INTPND
Uart_Printf("Sended a data=%d \n",rSIODAT);
}
unsigned char ReceptSIOData(void)
{
rSIOCON|=BIT_SIO_START;//Start to shift
while(!(rINTPND&BIT_SIO));//wait the shift to complete
rI_ISPC|=BIT_SIO;//Clear the flag of SIO_INTPND
Uart_Printf("recepted a data=%d \n",rSIODAT);
return rSIODAT;
}
void Main(void)
{
unsigned char temp=0;
rSYSCFG=CACHECFG; // Using 8KB Cache//
Port_Init();
SIO_Init();
Uart_Init(0,57600);//initalize UART0,baud=57600
Delay(10);
Uart_Select(0); //Select UART0
Uart_Printf("Enter Main program \n");
while(1)
{
SendSIOData(8);
temp=ReceptSIOData();
Led_Display(0x0);
Delay(2000);
Led_Display(0x7);
Delay(2000);
SendSIOData(50);
temp=ReceptSIOData();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -