完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
你好,
我正在尝试使用Discovery套件为SPC560D30L3设备使用串行驱动程序(我已将SPC560D40替换为SPC560D30 MCU)。当我尝试为缓冲区大小配置“串行驱动程序设置”时,它只接受16的值。它可以吗?根据HAL文档,默认值为16.它的有效范围是多少?我尝试输入1,2,3等的值,但它给出了一个错误,因为它不正确,导致我无法生成应用程序。错误的原因是什么?还需要其他设置吗? 其次,我试图读取或写入串行缓冲区/驱动程序。我尝试使用函数'sdGet'和'sdPut'来读取/写入串行的单字节。我能够读取SD1监视窗口内显示的字节,但无法将其传回终端。我使用正确的功能来实现这一目标吗?任何指导/帮助将受到高度赞赏。 提前致谢。 麦克风。 #serial 以上来自于谷歌翻译 以下为原文 Hello, I am trying to use the serial driver for SPC560D30L3 device using Discovery kit (I have replaced SPC560D40 with SPC560D30 MCU). When I try to configure the 'Serial Driver Settings' for buffer size, it only accepts value of 16. Is it ok? As per HAL document, the default value is 16. What is the valid range for it? I tried entering values of 1, 2, 3 etc but it gives an error as incorrect value which prevents me from generating the application. What is the reason for the error? Any other settings required? Secondly, I am trying to read or write to the serial buffer/driver. I tried using functions 'sdGet' and 'sdPut' for reading / writing single byte to the serial. I am able to read the byte as it shows inside the watch window for SD1 but not able to transmit it back to terminal. Am I using correct function to achieve this? Any guidance/help will be highly appreciated. Thanks in advance. Mike. #serial |
|
相关推荐
9个回答
|
|
你好迈克,
缓冲区大小应大于4。 在串口上传回它 你应该使用这个API: 无论如何,您可以使用包含shell终端的OS ChibiOS,您可以根据需要自定义它。 (cf shell_cmd。*) 最好的祝福 二万 以上来自于谷歌翻译 以下为原文 Hello Mike , The buffer size should be greater than 4. to transmit it back on serial port you should use this API :
Anyway , you can use an OS ChibiOS which contains a shell terminal that you can customize as you want. (cf shell_cmd.*) Best regards Erwan |
|
|
|
你好,Erwan,
谢谢回复。 之前我使用函数'chnRead'和'chnWrite'成功地从串行驱动程序读取和写入。我使用SDx状态实现了一个状态机。我的问题是如何处理串行驱动程序和应用程序层之间的握手?我发现SD_READY是接收或发送都可以发生的状态,但是当串行驱动器接收到字符或字节时,指示如何处理?即使SDx.events.flags只处理奇偶校验,溢出等状态,但是没有收到字符或字节的握手?是否需要检查DRF或DTF或RMB标志以确保串行活动结束?我在HAL驱动程序中看到了这个处理但app层如何处理呢?我每次调用函数'chnRead'来获取通过串行接收的字节。即使没有收到字节,也会调用此方法。怎么处理? 提前致谢。 麦克风。 以上来自于谷歌翻译 以下为原文 Hello Erwan, Thanks for the reply. Earlier I did succeed using the functions 'chnRead' and 'chnWrite' for reading and writing from serial driver. I implemented a state machine using SDx states. My question is how the handshaking between serial driver and application layer is handled? I find that SD_READY is the state when both receive or transmit can take place but how is the indication to handle when a character or a byte is received by the serial driver? Even the SDx.events.flags handle only the status for parity, overrun etc but no handshaking for character or byte received or not? Is it required to check the DRF or DTF or RMB flags to ensure that the serial activity is over? I see this handling inside the HAL driver but app layer how to handle it? I am calling function 'chnRead' every time to get a byte received over serial. This is called even if no byte is received. How to handle it? Thanks in advance. Mike. |
|
|
|
嗨,
队列状态也有事件标志: 当RX队列变为非空时,引发CHN_INPUT_AVAILABLE。 当TX队列变空时(UART仍在传输从队列中获取的最后一个字节),引发CHN_OUTPUT_EMPTY。 关于API,还有一些带有超时的函数变体,这可能有助于您实现状态机并具有通信超时的转换,请参阅: chnPutTimeout(),chnGetTimeout(),chnReadTimeout()和chnWriteTimeout()。 乔瓦尼 以上来自于谷歌翻译 以下为原文 Hi, There are event flags also for the status of queues: CHN_INPUT_AVAILABLE is raised when the RX queue becomes non-empty. CHN_OUTPUT_EMPTY is raised when the TX queue becomes empty (the UART is still transmitting the last byte fetched from the queue). About the API, there are also function variants with timeout, this could help in case you are implementing a state machine and have transitions for communication timeouts, see: chnPutTimeout(), chnGetTimeout(), chnReadTimeout() and chnWriteTimeout(). Giovanni |
|
|
|
你好Giovanni,
感谢您的回复。如果我理解正确,以下实现是否正确? 案例SD_READY: if(CHN_INPUT_AVAILABLE == SD1.event.flags) { chnReadTimeout(& SD1,(uint8 *)& sw_val,1,TIME_INFINITE); } 打破; 如果它是正确的,它就不起作用。我没有收到任何字符但是如果我删除了标志检查,它就可以了。 在此先感谢您的帮助。 麦克风。 以上来自于谷歌翻译 以下为原文 Hello Giovanni, Thanks for your reply. If I understand correctly, is the following implementation correct? case SD_READY: if (CHN_INPUT_AVAILABLE == SD1.event.flags) { chnReadTimeout(&SD1, (uint8 *)&sw_val, 1, TIME_INFINITE); } break; If it is correct, it is not working. I do not receive any character but if I remove the flag checking, it works. Thanks in advance for your help. Mike. |
|
|
|
如果检查数据可用性,那么您可能希望使用TIME_IMMEDIATE而不是TIME_INFINITE,这样您就不会阻塞读取函数,该函数将阻塞,直到读取所有指定的字节,即使尚未在队列中。
还有一点,为什么要检查驱动程序状态?启动后,它将始终为SD_READY。另请注意,当状态标志更改时,您可以进行回调。 此外,使用osalEventGetAndClearFlags()来读取标志,此函数返回当前掩码并清除它(如果您不清除标志,您将如何判断更多数据到达)。 有几种方法可以使用驱动程序: 1)Superloop以非阻塞方式检查标志和读/写(TIME_IMMEDIATE)。 2)Superloop以阻塞方式使用API(TIME_INFINITE或指定超时),除了错误检测之外不需要检查标志。 3)在驱动程序回调中,如果您正在实现某种状态机,这将特别有用。 4)如果您使用RTOS,那么您可能会以阻止方式使用驱动程序执行专用任务。 乔瓦尼 以上来自于谷歌翻译 以下为原文 If you check for data availability then you may want to use TIME_IMMEDIATE, not TIME_INFINITE, this way you will not block into the read function which would block until all the specified bytes are read, even if not yet in the queue. Another point, why you want to check the driver state? after starting it, it will always be SD_READY. Also note that you can have a callback when the status flags change. Also, use osalEventGetAndClearFlags() in order to read flags, this functions returns the current mask and clears it (if you don't clear the flags how would you tell that MORE data arrived). There are several ways to use the driver: 1) Superloop checking flags and reading/writing in a non blocking way (TIME_IMMEDIATE). 2) Superloop using the API in a blocking way (TIME_INFINITE or specifying timeouts), no need to check flags except for error detection. 3) From within the driver callbacks, this is especially useful if you are implementing some kind of state machine. 4) If you use an RTOS then you may have a dedicated task using the driver in a blocking way. Giovanni |
|
|
|
感谢Giovanni的澄清。
对于回调,“应用程序配置”的哪个部分提供配置回调函数? ADC或PWM具有这样的配置,但是对于串行,它没有找到。 关于标志处理,哪个文档提到了这个函数及其语法?我试着查看.chm文件,但无法找到它。 谢谢。 麦克风。 以上来自于谷歌翻译 以下为原文 Thanks Giovanni for clarifications. For callback, which section of 'Application Configuration' offers to configure the callback function? ADC or PWM have such configuration but for serial it is not found. Regarding the flag handling, which document mentions about this function and its syntax? I tried looking at .chm documents but could not locate it. Thanks. Mike. |
|
|
|
嗨,
串行驱动程序使用不同的回调方法(事件源),您需要在运行时将回调向量设置为SDx结构,在那里查看事件源(您也可以将其还原为NULL)。 请注意,使用RTOS时,事件源可以映射到OS自己的事件标志处理机制,而不是直接回调。 乔瓦尼 以上来自于谷歌翻译 以下为原文 Hi, The serial driver uses a different callback method (event sources), you need to set the callback vector into the SDx structure at runtime, see the event sources there (you can also revert it back to NULL). Note that when using an RTOS the event sources can be mapped to the OS own event flags handling mechanism and not have a direct callback. Giovanni |
|
|
|
你好Giovanni,
感谢您的回复。 我的应用程序不使用任何RTOS。您能否详细解释/详细说明“事件源”并定义回调向量?我可以参考哪个文件? 谢谢。 麦克风。 以上来自于谷歌翻译 以下为原文 Hello Giovanni, Thanks for your reply. My application does not use any RTOS. Can you please explain/elaborate more on 'event source' and defining the callback vector? Which document can I refer for this? Thanks. Mike. |
|
|
|
你好迈克,
回调向量(函数指针)是捕获事件的非常有效的方法。 对于SPC5-HAL驱动程序配置,当处理中断时...将调用回调。 最好的祝福 二万 以上来自于谷歌翻译 以下为原文 Hello Mike , a callback vector(function pointer) is very efficient way to catch an event. for a SPC5-HAL driver configuration, when an interruption is handled .. the callback is called. Best Regards Erwan |
|
|
|
只有小组成员才能发言,加入小组>>
请教:在使用UDE STK时,单片机使用SPC560D30L1,在配置文件怎么设置或选择?里面只有SPC560D40的选项
2719 浏览 1 评论
3236 浏览 1 评论
请问是否有通过UART连接的两个微处理器之间实现双向值交换的方法?
1807 浏览 1 评论
3645 浏览 6 评论
6033 浏览 21 评论
1334浏览 4评论
208浏览 3评论
196浏览 3评论
对H747I-DISCO写程序时将CN2的st-link复用为usart1,再次烧录时无法检测到stlink怎么解决?
350浏览 2评论
STM32G474RE芯片只是串口发个数据就发烫严重是怎么回事?
441浏览 2评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-20 16:54 , Processed in 1.290517 second(s), Total 93, Slave 77 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号