硬件平台:launchPad TMS570ls12x
软件:我是按照HAL code generator 的帮助文档中的教程操作的,结果成功了,串口功能使用正常,但是该教程是针对SCI2的,
如图一:
所以我照葫芦画瓢,重新新建了CCS工程,以及使用HAL code generator 使能了SCI,
如图二
main.c代码如下
/* USER CODE BEGIN (0) */
/* USER CODE END */
/* Include Files */
#include "sys_common.h"
/* USER CODE BEGIN (1) */
#include "gio.h"
#include "reg_sci.h"
#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 sciREG
/* 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) */
void wait(uint32 time);
/* USER CODE END */
int main(void)
{
/* USER CODE BEGIN (3) */
gioInit();
sciInit();
while(1)
{
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 */
gioToggleBit(gioPORTB, 1);
gioToggleBit(gioPORTB, 2);
wait(5000000);
}
/* 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)
{
while(time)
{
time--;
}
}
/* USER CODE END */
然后生成了代码,并在main函数中参照SCI2修改了相应的代码.但是用示波器测量SCITX端口发现始终为低电平,没有任何数据信号.
请教一下大家,SCI的使用跟SCI2有什么需要特别注意的地方么?