1129 views|0 replies

3836

Posts

19

Resources
The OP
 

Simple transplantation of printf function of msp430 [Copy link]

In the past few months, I have been working on a project of RGB color sensor based on TCS34725. The main control I use is MSP430. When debugging, I usually use 485 bus to send to the upper computer (computer or upper host computer). At first, I used the serial port sending function to send directly, but it was very inconvenient to display many data, such as floating point numbers and data streams with special formats. Previously, I used the serial port sending function to group the functions by myself, which called the int putchar(char *) function.

So I spent a few minutes writing a putchar function, which I have used and it really worked... Thinking back to the stupid way I constructed the formats one by one and converted numbers into strings, now I can finally use the printf function...

int putchar(int ch)
{
if (ch == '\n')
{
RS485Send_Byte(0x0d);
}
RS485Send_Byte(ch); //Send data from the serial port
return (ch);
}

This post is from Microcontroller MCU
 

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list