完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
电子发烧友论坛|
|
|
相关推荐
2个回答
|
|
|
嗨,大家好:
我有几个关于STM8的问题。我在STVD中使用Cosmic编译器并尝试使用IDE附带的模拟器。我能够运行一些简单的程序,但我想做的是将字符从模拟器导出到主机。 到目前为止,我追求了一些途径。一个途径是使用printf打印到控制台。以下是我用的代码...... #include''stdio.h'' #include''iostm8a.h'' #define TRDE 0x80 / *发送就绪位* / #define rim()_asm(''rim'') / *输出一个字符输出 * COSMIC Software版权所有(c)1998 * / / *输出一个字符 * / char putchar(char c) { char VCAST_OUTCH = c; if(c ==' n') { / *把' r'放到硬件这里* / while(!(USART_SR& TRDE)); / *等待READY * / USART_DR =' r'; /* 发送 */ } / *把c放到这里硬件* / while(!(USART_SR& TRDE)); / *等待READY * / USART_DR =' r'; /* 发送 */ 返回(c); } 主要() { USART_BRR1 = 0xc9; / *波特率参数* / USART_CR1 = 0x00; / *字长* *参数 USART_CR2 = 0x2c; / *中断参数* / 轮缘(); / *授权中断* / printf(''hello world''); printf(''再来一次!''); } 我可能没有完整的代码,因为我不知道如何将这些字符发送到控制台。如果是这种情况,有人可以告诉我吗? 研究这个论坛,我也意识到在发布说明中,ST报告说STM8模拟器没有实现外围设备,所以另一方面,可能没有任何方法可以进入该控制台窗口。 因此,我尝试将发送到putchar的字符存储到要通过调试器(gdb)保存在主机上的文件中。我的想法是做类似的事情: fopen number myfile.txt watch putchar():char_being_written {将char放入文件的操作} 走 fclose file_number 我试图fopen 1 out.txt,但是GDB只报告了'''fopen error''而没有太多细节。我也不确定访问将char值写入文件的操作 - 在其他环境中,你显然可以做fwrite,但在这里似乎并非如此。 有人可以给我一些指示吗? 谢谢! 以上来自于谷歌翻译 以下为原文 Hi everyone: I have a few questions about STM8. I am using the Cosmic compiler within STVD and trying to use the simulator that comes with the IDE. I am able to run some simple programs, however what I would like to do is to export characters out of the simulator to the host. I pursued a few avenues so far. One avenue was to use printf to print to the console. The following is the code I used... #include ''stdio.h'' #include ''iostm8a.h'' #define TRDE 0x80 /* transmit ready bit */ #define rim() _asm(''rim'') /* PUT A CHARACTER TO OUTPUT * Copyright (c) 1998 by COSMIC Software */ /* output a character */ char putchar(char c) { char VCAST_OUTCH = c; if (c == 'n') { /* put 'r' to hardware here */ while (!(USART_SR & TRDE)); /* wait for READY */ USART_DR = 'r'; /* send it */ } /* put c to hardware here */ while (!(USART_SR & TRDE)); /* wait for READY */ USART_DR = 'r'; /* send it */ return (c); } main() { USART_BRR1 = 0xc9; /* parameter for baud rate */ USART_CR1 = 0x00; /* parameter for word length */ USART_CR2 = 0x2c; /* parameters for interrupt */ rim(); /* authorize interrupts */ printf(''hello world''); printf(''hi again!''); } I might not have a complete code since I don`t know how to send these characters to the console. If this is the case, could someone kindly let me know? Researching on this forum, I also realized that in the release note, ST reports that the STM8 simulator does not implement peripherals, so on the other hand, there might not be any way to get to that console window. So, I tried to store characters sent to putchar to a file to be saved on the host through the debugger (gdb). My idea is to do something similar to this: fopen number myfile.txt watch putchar():char_being_written { operation to put the char in the file } go fclose file_number I tried to do fopen 1 out.txt, but GDB just reported `''fopen error'' without much details. I am also unsure of the operation to access to write the char values to file - in other environments, you can apparently do fwrite, but it does not seem to be the case here. Could someone give me a few pointers? Thanks! |
|
|
|
|
|
嗨,
在库stdio中定义的printf()函数调用putchar()函数在控制台上发送数据。在你的情况下你已经个性化了putchar()函数来向COM发送字符(超级终端) 要读取数据,您需要个性化getchar()函数。 您可以参考STM8S FWLibrary中的USART_Printf示例。 问候 mozra 以上来自于谷歌翻译 以下为原文 Hi, The printf() function as it defined in the library stdio call the putchar() function to send data on the console, In your case you have personalized the putchar() function to send characters to the COM (HyperTerminal) To read data you need to personalize the getchar() function. You can refer to the USART_Printf example in the STM8S FWLibrary. Regards mozra |
|
|
|
|
只有小组成员才能发言,加入小组>>
stm32mp157的异核通信的rpmsg_sdb的m4固件和a7驱动该如何编写?
1469 浏览 0 评论
stm32f103用freertos对一个采样率为1kHz的传感器,进行采样,数据出差
1521 浏览 0 评论
请教:在使用UDE STK时,单片机使用SPC560D30L1,在配置文件怎么设置或选择?里面只有SPC560D40的选项
3668 浏览 1 评论
3860 浏览 1 评论
请问是否有通过UART连接的两个微处理器之间实现双向值交换的方法?
2477 浏览 1 评论
STM32H7打开DCache后,出现了串口接收信息为空的现象,是哪里出了问题?
749浏览 5评论
用NANO STM32F103RBT6的开发板烧录不了是哪里出了问题?
681浏览 5评论
728浏览 5评论
外部中断触发类型为双边沿触发,进入中断回调后有什么办法判断该边沿是上升沿还是下降沿?
969浏览 5评论
STM32L071CBT6低温环境下无法正常工作是什么原因引起的?
773浏览 5评论
/9
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-12-12 06:52 , Processed in 0.919205 second(s), Total 42, Slave 35 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191

淘帖
855