OpenEdv-开源电子网

 找回密码
 立即注册
正点原子全套STM32/Linux/FPGA开发资料,上千讲STM32视频教程免费下载...
查看: 6646|回复: 3

pwn输出遇见问题了,

[复制链接]

62

主题

284

帖子

0

精华

高级会员

Rank: 4

积分
947
金钱
947
注册时间
2014-11-22
在线时间
145 小时
发表于 2014-11-30 15:32:18 | 显示全部楼层 |阅读模式
5金钱
大神来帮我看看,个人看了网上博客里面写的pwn的波,然后有看了原子哥的程序后,打算自己写一个显示脉冲时间的函数,但是出错的,望将错误的地方指出,小白感谢不尽

pwn.rar

3.48 MB, 下载次数: 111

最佳答案

查看完整内容[请看2#楼]

回复【2楼】Scy: --------------------------------- 看错了,库函数里面有,但是我用的这个里面没有,呵呵,犯了
爱上一匹野马,可惜放走了,就不回头了
正点原子逻辑分析仪DL16劲爆上市
回复

使用道具 举报

62

主题

284

帖子

0

精华

高级会员

Rank: 4

积分
947
金钱
947
注册时间
2014-11-22
在线时间
145 小时
 楼主| 发表于 2014-11-30 15:32:19 | 显示全部楼层
回复【2楼】Scy:
---------------------------------
看错了,库函数里面有,但是我用的这个里面没有,呵呵,犯了
爱上一匹野马,可惜放走了,就不回头了
回复

使用道具 举报

20

主题

232

帖子

0

精华

中级会员

Rank: 3Rank: 3

积分
335
金钱
335
注册时间
2013-6-1
在线时间
0 小时
发表于 2014-11-30 17:21:04 | 显示全部楼层
这几句是你创造出来的吗 = =。。。   
[mw_shl_code=c,true]TIM_OCInitStructure.TIM_Channel = TIM_Channel_1;//选择输出端的通道 TIM_ICInitStructure.TIM_ICMode = TIM_ICMode_PWMI;[/mw_shl_code]
[mw_shl_code=c,true] [/mw_shl_code] [mw_shl_code=c,true]typedef struct { uint16_t TIM_OCMode; /*!< Specifies the TIM mode. This parameter can be a value of @ref TIM_Output_Compare_and_PWM_modes */ uint16_t TIM_OutputState; /*!< Specifies the TIM Output Compare state. This parameter can be a value of @ref TIM_Output_Compare_state */ uint16_t TIM_OutputNState; /*!< Specifies the TIM complementary Output Compare state. This parameter can be a value of @ref TIM_Output_Compare_N_state @note This parameter is valid only for TIM1 and TIM8. */ uint16_t TIM_Pulse; /*!< Specifies the pulse value to be loaded into the Capture Compare Register. This parameter can be a number between 0x0000 and 0xFFFF */ uint16_t TIM_OCPolarity; /*!< Specifies the output polarity. This parameter can be a value of @ref TIM_Output_Compare_Polarity */ uint16_t TIM_OCNPolarity; /*!< Specifies the complementary output polarity. This parameter can be a value of @ref TIM_Output_Compare_N_Polarity @note This parameter is valid only for TIM1 and TIM8. */ uint16_t TIM_OCIdleState; /*!< Specifies the TIM Output Compare pin state during Idle state. This parameter can be a value of @ref TIM_Output_Compare_Idle_State @note This parameter is valid only for TIM1 and TIM8. */ uint16_t TIM_OCNIdleState; /*!< Specifies the TIM Output Compare pin state during Idle state. This parameter can be a value of @ref TIM_Output_Compare_N_Idle_State @note This parameter is valid only for TIM1 and TIM8. */ } TIM_OCInitTypeDef; /** * @brief TIM Input Capture Init structure definition */ typedef struct { uint16_t TIM_Channel; /*!< Specifies the TIM channel. This parameter can be a value of @ref TIM_Channel */ uint16_t TIM_ICPolarity; /*!< Specifies the active edge of the input signal. This parameter can be a value of @ref TIM_Input_Capture_Polarity */ uint16_t TIM_ICSelection; /*!< Specifies the input. This parameter can be a value of @ref TIM_Input_Capture_Selection */ uint16_t TIM_ICPrescaler; /*!< Specifies the Input Capture Prescaler. This parameter can be a value of @ref TIM_Input_Capture_Prescaler */ uint16_t TIM_ICFilter; /*!< Specifies the input capture filter. This parameter can be a number between 0x0 and 0xF */ } TIM_ICInitTypeDef;[/mw_shl_code]
仔细看上面的结构体,有没有你写的成员变量...

还有...看你写的,你应该是想用TIM3的两个通道,一个输出PWM波(是PWM不是PWN),一个输入捕获判断高电平时间。那你好歹也用俩通道啊,全部用Channel1你觉得可行吗?

回复

使用道具 举报

62

主题

284

帖子

0

精华

高级会员

Rank: 4

积分
947
金钱
947
注册时间
2014-11-22
在线时间
145 小时
 楼主| 发表于 2014-12-1 17:49:45 | 显示全部楼层
回复【2楼】Scy:
---------------------------------
我是用库函数里面的呀
/* The following example illustrates how to configure the TIM2 in
PWM Input mode: The external signal is connected to TIM2 CH1 pin,
the Rising edge is used as active edge, the TIM2 CCR1 is used to
compute the frequency value the TIM2 CCR2 is used to compute the
duty cycle value */
TIM_DeInit(TIM2);
TIM_ICStructInit(&TIM_ICInitStructure);
TIM_ICInitStructure.TIM_ICMode = TIM_ICMode_PWMI;
TIM_ICInitStructure.TIM_Channel = TIM_Channel_1;
TIM_ICInitStructure.TIM_ICPolarity = TIM_ICPolarity_Rising;
TIM_ICInitStructure.TIM_ICSelection = TIM_ICSelection_DirectTI;
TIM_ICInitStructure.TIM_ICPrescaler = TIM_ICPSC_DIV1;
TIM_ICInitStructure.TIM_ICFilter = 0x0;
TIM_ICInit(TIM2, &TIM_ICInitStructure);
爱上一匹野马,可惜放走了,就不回头了
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则



关闭

原子哥极力推荐上一条 /2 下一条

正点原子公众号

QQ|手机版|OpenEdv-开源电子网 ( 粤ICP备12000418号-1 )

GMT+8, 2025-6-28 12:28

Powered by OpenEdv-开源电子网

© 2001-2030 OpenEdv-开源电子网

快速回复 返回顶部 返回列表