1、建立一个新的 HALCoGen 项目,和前面两个实验的流程基本一样。
1)在 HALCoGen 的开发界面中,通过菜单选择 File–New–Project 建立一
个新的项目。
/* USER CODE BEGIN (0) */
/* USER CODE END */
/* Include Files */
#include "sys_common.h"
/* USER CODE BEGIN (1) */
#include "sci.h"
#define TSIZE1 10
uint8 TEXT1[TSIZE1]= {'H','E','R','C','U','L','E','S',' ',' '};
#define TSIZE2 18
uint8 TEXT2[TSIZE2]= {'M','I','C','R','O','C','O','N','T','R','O','L','L','E','R','S',' ',' '};
#define TSIZE3 19
uint8 TEXT3[TSIZE3]= {'T','E','X','A','S',' ','I','N','S','T','R','U','M','E','N','T','S','\n','\r'};
void sciDisplayText(sciBASE_t *sci, uint8 *text, uint32 length);
void wait(uint32 time);
#define UART scilinREG
/* USER CODE END */
/** @fn void main(void)
* @brief Application main function
* @note This function is empty by default.
*
* This function is called after startup.
* The user can use this function to implement the application.
*/
/* USER CODE BEGIN (2) */
/* USER CODE END */
int main(void)
{
/* USER CODE BEGIN (3) */
sciInit(); /* initialize sci/sci-lin */
/* even parity , 2 stop bits */
while(1) /* continious desplay */
{
sciDisplayText(UART,&TEXT1[0],TSIZE1); /* send text code 1 */
sciDisplayText(UART,&TEXT2[0],TSIZE2); /* send text code 2 */
sciDisplayText(UART,&TEXT3[0],TSIZE3); /* send text code 3 */
wait(200);
};
/* USER CODE END */
return 0;
}
/* USER CODE BEGIN (4) */
void sciDisplayText(sciBASE_t *sci, uint8 *text,uint32 length)
{
while(length--)
{
while ((UART->FLR & 0x4) == 4); /* wait until busy */
sciSendByte(UART,*text++); /* send out text */
};
}
void wait(uint32 time)
{
time--;
}
/* USER CODE END */