MSP430(CCS工程下)添加printf实现打印功能

要注意同时添加fputc和fputs两个函数。

int fputc(int ch, FILE *f)
{
// if (ch == ‘\n’)
//{
// send_char(0x0d) ;
//}
send_char(ch); //从串口发出数据
return (ch);
}

int fputs(const char *_ptr, register FILE *_fp)
{
uint16_t i, len;
len = strlen(_ptr);
for(i=0; i<len; i++)
{
EUSCI_A_UART_transmitData(EUSCI_A0_BASE,(unsigned char)_ptr[i] );
// while (!EUSCI_A_UART_getInterruptStatus(EUSCI_A0_BASE,
// EUSCI_A_UART_TRANSMIT_INTERRUPT_FLAG));
// EUSCI_A_CMSIS(EUSCI_A0_BASE)->IFG |= (EUSCI_A_UART_TRANSMIT_INTERRUPT_FLAG);
}
return len;
}

补充:EUSCI_A_UART_transmitData函数说明
//*****************************************************************************
//
//! \brief Transmits a byte from the UART Module.Please note that if TX
//! interrupt is disabled, this function manually polls the TX IFG flag waiting
//! for an indication that it is safe to write to the transmit buffer and does
//! not time-out
//!
//! This function will place the supplied data into UART transmit data register
//! to start transmission
//!
//! \param baseAddress is the base address of the EUSCI_A_UART module.
//! \param transmitData data to be transmitted from the UART module
//!
//! Modified bits of \b UCAxTXBUF register.
//!
//! \return None
//
//*****************************************************************************
extern void EUSCI_A_UART_transmitData(uint16_t baseAddress,
uint8_t transmitData);

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值