完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
我正在使用STM8S003F3U。该MCU与SPIRIT1收发器一起使用。使用OOK调制,SPIRIT1的原始数据将被发送到MCU上的引脚PC3。由于我的发送器的数据速率不一致,我需要能够测量数据的脉冲高电平时间。为此,我认为需要做以下事情:
1)将PC3配置为其备用引脚功能(tiM1_CHANNEL_1_N)。我不知道该怎么做。有人可以提供代码示例吗? 2)使用两个ISR(一个用于上升沿,一个用于下降沿)配置TIM1捕获通道,以便可以测量脉冲时间。 ST有一些基本的代码,但目前还不清楚如何做到这一点。有人可以提供代码示例吗? 完成这两个步骤后,我可以导出比特率并解码消息。我们非常感谢您提供的任何帮助! 谢谢, 诺亚 #stm8s003f3u #alternate#spirit1 #pwm-input-capture#alternate-function-selection 以上来自于谷歌翻译 以下为原文 I am using STM8S003F3U. This MCU is being used with a SPIRIT1 transceiver. Using OOK modulation, the SPIRIT1's raw data is being sent to pin PC3 on the MCU. Because my transmitter's data rate is inconsistent, I need to be able to measure the pulse HIGH time of the data coming across. To do this, it is my belief that the following needs to be done: 1) Configure PC3 to its alternative pin function (TIM1_CHANNEL_1_N). I do not know how to do this. Can someone provide a code example? 2) Configure the TIM1 capture channel with two ISRs (one for rising edges and one for falling edges), so that the pulse time can be measured. There is some rudimentary code from ST, but it is unclear how to do this. Can someone provide a code example? Once these two steps are complete, I can derive the bit rate and decode messages. Any help that can be provided is much appreciated! Thank you, Noah #stm8s003f3u #alternate #spirit1 #pwm-input-capture #alternate-function-selection |
|
相关推荐
7个回答
|
|
你确定Negated引脚可以用作输入吗?我知道它不能在STM32设计上,不确定STM8。
数据表应提供备用功能引脚映射选项的详细信息。 以上来自于谷歌翻译 以下为原文 Are you sure the Negated pin can be used as an Input? I know it can't on the STM32 designs, not sure of the STM8. The Data Sheet should provide details of the Alternate Function pin mapping options. |
|
|
|
克莱夫,
你是ST员工吗?我问,因为如果你是,我非常失望地被问到一个ST应该比我知道得更好的问题。这种反应毫无用处,也无助于解决这个问题。 已经彻底搜索了数据表,应用笔记和示例设计。坦率地说,由于缺乏ST提供的支持,我们即将选择另一个MCU。如果有人可以提供帮助,那么继续使用ST的部件也许是有意义的。 以上来自于谷歌翻译 以下为原文 Clive, Are you a ST employee? I ask because if you are, I am extremely disappointed in being asked a question that ST should know far better than I. This response is useless and in no way assists in solving this issue. The datasheets, application notes and example designs have been thoroughly searched. Quit frankly, we are on the verge a selecting another MCU due to the lack of support that ST provides. If anyone can help, then perhaps it makes sense to continue to use ST's parts. |
|
|
|
克莱夫,
我认为这是一个撰写ST技术支持专业人员,ST的实际员工的论坛。如果您也是开发人员并且没有正式关联ST,我很抱歉向您发泄。这是我第十次就此问题或相关问题与ST联系,而且没有回应。 现在,感谢您分享您拥有的信息。无论选择哪个引脚 - 这都可以很容易地改变 - 仍然需要测量PWM脉冲时间。例如,如果使用了引脚PC5(TIM2_Channel1)并使用了PWMI Init功能(见下文),那么如何提取脉冲时间并管理定时器。如果有任何示例代码,那将是有用的。 / ** * @brief根据指定的参数在PWM输入模式下配置TIM2外设。 * @param TIM2_Channel指定来自@ref TIM2_Channel_TypeDef的输入捕获通道。 * @param TIM2_ICPolarity指定来自@ref TIM2_ICPolarity_TypeDef的输入捕获极性。 * @param TIM2_ICSelection指定@ref TIM2_ICSelection_TypeDef的输入捕获选择。 * @param TIM2_ICPrescaler指定来自@ref TIM2_ICPSC_TypeDef的输入捕获预分频器。 * @param TIM2_ICFilter指定输入捕获过滤器值(值可以是0x00到0x0F之间的整数)。 * @retval没有 * / void TIM2_PWMIConfig(TIM2_Channel_TypeDef TIM2_Channel, TIM2_ICPolarity_TypeDef TIM2_ICPolarity, TIM2_ICSelection_TypeDef TIM2_ICSelection, TIM2_ICPSC_TypeDef TIM2_ICPrescaler, uint8_t TIM2_ICFilter) { uint8_t icpolarity =(uint8_t)TIM2_ICPOLARITY_RISING; uint8_t icselection =(uint8_t)TIM2_ICSELECTION_DIRECTTI; / *检查参数* / assert_param(IS_TIM2_PWMI_CHANNEL_OK(TIM2_Channel)); assert_param(IS_TIM2_IC_POLARITY_OK(TIM2_ICPolarity)); assert_param(IS_TIM2_IC_SELECTION_OK(TIM2_ICSelection)); assert_param(IS_TIM2_IC_PRESCALER_OK(TIM2_ICPrescaler)); / *选择相反的输入极性* / if(TIM2_ICPolarity!= TIM2_ICPOLARITY_FALLING) { icpolarity =(uint8_t)TIM2_ICPOLARITY_FALLING; } 其他 { icpolarity =(uint8_t)TIM2_ICPOLARITY_RISING; } / *选择相反的输入* / if(TIM2_ICSelection == TIM2_ICSELECTION_DIRECTTI) { icselection =(uint8_t)TIM2_ICSELECTION_INDIRECTTI; } 其他 { icselection =(uint8_t)TIM2_ICSELECTION_DIRECTTI; } if(TIM2_Channel == TIM2_CHANNEL_1) { / * TI1配置* / TI1_Config((uint8_t)TIM2_ICPolarity,(uint8_t)TIM2_ICSelection, (uint8_t)TIM2_ICFilter); / *设置输入捕获预分频值* / TIM2_SetIC1Prescaler(TIM2_ICPrescaler); / * TI2配置* / TI2_Config(icpolarity,icselection,TIM2_ICFilter); / *设置输入捕获预分频值* / TIM2_SetIC2Prescaler(TIM2_ICPrescaler); } 其他 { / * TI2配置* / TI2_Config((uint8_t)TIM2_ICPolarity,(uint8_t)TIM2_ICSelection, (uint8_t)TIM2_ICFilter); / *设置输入捕获预分频值* / TIM2_SetIC2Prescaler(TIM2_ICPrescaler); / * TI1配置* / TI1_Config((uint8_t)icpolarity,icselection,(uint8_t)TIM2_ICFilter); / *设置输入捕获预分频值* / TIM2_SetIC1Prescaler(TIM2_ICPrescaler); } } 以上来自于谷歌翻译 以下为原文 Clive, I thought this was a forum for writing ST technical support professionals, actual employees of ST. I am sorry for venting to you, if you too are a developer and not formally associated ST. This is quite literally the 10th time I have contacted ST on this or a related issue, and there has been no response. Now, thank you for sharing the information that you have. Regardless of the pin that has been selected - this can be changed quite easily - there is still the need to measuring the PWM pulse time. If, for example, pin PC5 (TIM2_Channel1) were used and the PWMI Init function were used (see below), how would one extract the pulse time and mange the timer. If there were any example code for this, it would be useful. /** * @brief Configures the TIM2 peripheral in PWM Input Mode according to the specified parameters. * @param TIM2_Channel specifies the Input Capture Channel from @ref TIM2_Channel_TypeDef. * @param TIM2_ICPolarity specifies the Input Capture Polarity from @ref TIM2_ICPolarity_TypeDef. * @param TIM2_ICSelection specifies the Input Capture Selection from @ref TIM2_ICSelection_TypeDef. * @param TIM2_ICPrescaler specifies the Input Capture Prescaler from @ref TIM2_ICPSC_TypeDef. * @param TIM2_ICFilter specifies the Input Capture Filter value (value can be an integer from 0x00 to 0x0F). * @retval None */ void TIM2_PWMIConfig(TIM2_Channel_TypeDef TIM2_Channel, TIM2_ICPolarity_TypeDef TIM2_ICPolarity, TIM2_ICSelection_TypeDef TIM2_ICSelection, TIM2_ICPSC_TypeDef TIM2_ICPrescaler, uint8_t TIM2_ICFilter) { uint8_t icpolarity = (uint8_t)TIM2_ICPOLARITY_RISING; uint8_t icselection = (uint8_t)TIM2_ICSELECTION_DIRECTTI; /* Check the parameters */ assert_param(IS_TIM2_PWMI_CHANNEL_OK(TIM2_Channel)); assert_param(IS_TIM2_IC_POLARITY_OK(TIM2_ICPolarity)); assert_param(IS_TIM2_IC_SELECTION_OK(TIM2_ICSelection)); assert_param(IS_TIM2_IC_PRESCALER_OK(TIM2_ICPrescaler)); /* Select the Opposite Input Polarity */ if (TIM2_ICPolarity != TIM2_ICPOLARITY_FALLING) { icpolarity = (uint8_t)TIM2_ICPOLARITY_FALLING; } else { icpolarity = (uint8_t)TIM2_ICPOLARITY_RISING; } /* Select the Opposite Input */ if (TIM2_ICSelection == TIM2_ICSELECTION_DIRECTTI) { icselection = (uint8_t)TIM2_ICSELECTION_INDIRECTTI; } else { icselection = (uint8_t)TIM2_ICSELECTION_DIRECTTI; } if (TIM2_Channel == TIM2_CHANNEL_1) { /* TI1 Configuration */ TI1_Config((uint8_t)TIM2_ICPolarity, (uint8_t)TIM2_ICSelection, (uint8_t)TIM2_ICFilter); /* Set the Input Capture Prescaler value */ TIM2_SetIC1Prescaler(TIM2_ICPrescaler); /* TI2 Configuration */ TI2_Config(icpolarity, icselection, TIM2_ICFilter); /* Set the Input Capture Prescaler value */ TIM2_SetIC2Prescaler(TIM2_ICPrescaler); } else { /* TI2 Configuration */ TI2_Config((uint8_t)TIM2_ICPolarity, (uint8_t)TIM2_ICSelection, (uint8_t)TIM2_ICFilter); /* Set the Input Capture Prescaler value */ TIM2_SetIC2Prescaler(TIM2_ICPrescaler); /* TI1 Configuration */ TI1_Config((uint8_t)icpolarity, icselection, (uint8_t)TIM2_ICFilter); /* Set the Input Capture Prescaler value */ TIM2_SetIC1Prescaler(TIM2_ICPrescaler); } } |
|
|
|
Clive对于阅读和理解数据表的需要是正确的。回复你帖子的人正试图提供帮助 - 因为他们可以选择保持沉默。他们花费时间和精力来帮助的事实应该受到赞赏。
至于你的问题。 1.可以编写代码或更改选项字节。 2.可能无法写入isrs来单独处理两个边缘,但肯定可以编写一个isr来处理两个边缘。 以上来自于谷歌翻译 以下为原文 Clive is right about the need to read and understand the data sheet. People responding to your post is trying to help - as they have the option to remain silent. The fact that they spent their time and effort to help should be appreciated. As to your questions. 1. Possible to write code, or to change the option bytes. 2. May not be possible to write to isrs to processed the two edges individually but certainly doable to write one isr to process both. |
|
|
|
|
|
|
|
对于高级工程师,您似乎有态度问题,并且能够处理提供给您的信息/建议。如果您对ST有疑问,可以使用分配给您的帐户的FAE和您正在使用的销售工程师。
http://www.st.com/content/ccc/resource/technical/document/reference_manual/9a/1b/85/07/ca/eb/4f/dd/CD00190271.pdf/files/CD00190271.pdf/jcr:内容/翻译/ en.CD00190271.pdf TIM上的仅输出引脚可以用作输入吗?一般不是。 以上来自于谷歌翻译 以下为原文 For a senior engineer you seem to have an attitude problem, and in ability to process information/suggestions provided to you. If you have a problem with ST take that up with the FAE assigned to your account and sales engineers you're working with. http://www.st.com/content/ccc/resource/technical/document/reference_manual/9a/1b/85/07/ca/eb/4f/dd/CD00190271.pdf/files/CD00190271.pdf/jcr:content/translations/en.CD00190271.pdf Can an output only pin on the TIM be used as an input? Generally not. |
|
|
|
不要担心实际的实施。相反,请考虑一下您的方法,然后找出实现它的方法。
两种基本方法可以做你想要的。 1.使用外部脉冲序列来连接更快的时钟。例如,有许多方法可以做到这一点。最简单的方法是在输入引脚上使用中断来触发定时器。 这种方法可以使用任何具有中断功能的引脚。但它有紧张情绪。更适合低速脉冲。 2.使用计时器的捕获功能。它是最准确的,没有抖动,但只能在某些引脚上完成。非常适合高速信号。 您只需要弄清楚哪种方法更适合您的应用程序。 以上来自于谷歌翻译 以下为原文 Don't worry about the actual implementation. Instead, think about your approach and then figure out a way to implement it. Two basic ways to do what you want. 1.use the external pulse train to gate an faster clock. Many ways to do that, for example. The simplest would be to use an interrupt on the input pin to trigger a timer. This approach can use any pin that's interrupt capable. But it has jitters. Better suited for low speed pulses. 2. Use the capture function of the timer. It is the most accurate, no jitter, but can only be done on certain pins. Great for high speed signals. You just need to figure out which works better for your application. |
|
|
|
只有小组成员才能发言,加入小组>>
请教:在使用UDE STK时,单片机使用SPC560D30L1,在配置文件怎么设置或选择?里面只有SPC560D40的选项
2635 浏览 1 评论
3208 浏览 1 评论
请问是否有通过UART连接的两个微处理器之间实现双向值交换的方法?
1783 浏览 1 评论
3610 浏览 6 评论
5988 浏览 21 评论
939浏览 4评论
1316浏览 4评论
在Linux上安装Atollic TRUEStudio的步骤有哪些呢?
584浏览 3评论
使用DMA激活某些外设会以导致外设无法工作的方式生成代码是怎么回事
1303浏览 3评论
1359浏览 3评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-23 10:40 , Processed in 1.123562 second(s), Total 60, Slave 54 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号