完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
电子发烧友论坛|
嗨,我刚刚开始使用STM8S003F3P TSSOP20设备进行开发。我一直在研究许多外围设备,这些外设已经很好,但现在遇到了障碍。我正在使用带有Raisonance工具集的STVD。
我要做的是在引脚1和引脚20上获得2个PWM信号,即tiM2_1和TIM2_2。我注意到,当使用固件库时,PWM没有出现,所以我试图做一些不同的实现,似乎没有人能够使PWM运行。因此,在调查配置的地址值(位于基址0x5300)后,我注意到CCMR1和CCMR2根本没有设置。它们位于0x5305和0x5306位置。即使我在指令完成后直接设置值并逐步执行,这些地址的值也保持不变。我认为芯片可能有问题,所以我尝试了几个不同的芯片,结果都是一样的。所以我正式坚持并需要帮助。我想知道是否有人看过这个或知道我做错了什么。 该芯片运行正常,因为在同一设备上,(相同的设置等)我已经能够获得SPI和TIM1上的EncoderMode完美运行。它似乎只是TIM2不会让我正确配置。 我所做的两个示例实现如下.... 地址定义: #define mCCMR1(*((vu8 *)(0x5305))) #define mCCMR2(*((vu8 *)(0x5306))) #define mCR1(*((vu8 *)(0x5300))) 然后在主要我有: TIM2-> PSCR = 0x00; TIM2-> ARRH = 0x03; TIM2-> ARRL = 0xE7; TIM2-> CCR1H = 0x01; TIM2-> CCR1L = 0xF4; TIM2-> CCR2H = 0x01; TIM2-> CCR2L = 0xF4; TIM2-> CCER1 = 0x33; mCCMR1 = 0x68; mCCMR2 = 0x68; mCR1 = 0x01; 在此版本中,CR1正确设置但CCMR1和CCMR2没有,它们保持为零。 另一个实施是: TIM2_DeInit(); TIM2_TimeBaseInit(TIM2_PRESCALER_1,999); //频道1 - IN1 TIM2_OC1Init(TIM2_OCMODE_PWM1,TIM2_OUTPUTSTATE_ENABLE,CCR1_Val,TIM2_OCPOLARITY_LOW); TIM2_OC1PreloadConfig(ENABLE); //频道2 - IN2 TIM2_OC2Init(TIM2_OCMODE_PWM1,TIM2_OUTPUTSTATE_ENABLE,CCR2_Val,TIM2_OCPOLARITY_LOW); TIM2_OC2PreloadConfig(ENABLE); TIM2_ARRPreloadConfig(ENABLE); TIM2_Cmd(ENABLE); 并且在此处发生相同的结果,除了CCMR1和CCMR2之外,所有配置寄存器似乎都被适当地写入。 任何输入都会有所帮助,谢谢你提前!! 以上来自于谷歌翻译 以下为原文 Hi, I have just recently started developing with the STM8S003F3P TSSOP20 device. I have been working through a number of peripherals, which have gone fine, but have now run into a roadblock. I am using the STVD with Raisonance toolset. What I am trying to do is get 2 PWM signals on the pins 1 and pin 20, that is TIM2_1 and TIM2_2. I noticed right off the bat that when using the firmware libraries, the PWMs didnt come up, so i tried to do a few different implementations and none seem to be able to make the PWMs go. So after investigating the address values for the configurations (located at base address 0x5300) i noticed that CCMR1 and CCMR2 are not getting set at all. These are at location 0x5305 and 0x5306. Even when i set the values directly and step through, right after the instruction completes, the value at those addresses remain unchanged. I thought the chip might be faulty so i tried it on a few different ones and all the same result. So im officially stuck and need help. I am wondering if anyone has seen this or knows what I am doing wrong. The chip is functioning correctly because on the same device, (same setup etc) i have been able to get SPI and the EncoderMode on TIM1 functioning perfectly. It just seems to be TIM2 that wont let me configure correctly. Two example implementations i have done are as follows.... addresses defined: #define mCCMR1 (*((vu8 *) (0x5305))) #define mCCMR2 (*((vu8 *) (0x5306))) #define mCR1 (*((vu8 *) (0x5300))) and then in main i have: TIM2->PSCR = 0x00; TIM2->ARRH = 0x03; TIM2->ARRL = 0xE7; TIM2->CCR1H = 0x01; TIM2->CCR1L = 0xF4; TIM2->CCR2H = 0x01; TIM2->CCR2L = 0xF4; TIM2->CCER1 = 0x33; mCCMR1 = 0x68; mCCMR2 = 0x68; mCR1 = 0x01; In this version, CR1 gets sets correctly but CCMR1 and CCMR2 do not, they remain at zero. Another implementation was: TIM2_DeInit(); TIM2_TimeBaseInit(TIM2_PRESCALER_1, 999); //Channel 1 - IN1 TIM2_OC1Init(TIM2_OCMODE_PWM1, TIM2_OUTPUTSTATE_ENABLE,CCR1_Val, TIM2_OCPOLARITY_LOW); TIM2_OC1PreloadConfig(ENABLE); //Channel 2 - IN2 TIM2_OC2Init(TIM2_OCMODE_PWM1, TIM2_OUTPUTSTATE_ENABLE,CCR2_Val, TIM2_OCPOLARITY_LOW); TIM2_OC2PreloadConfig(ENABLE); TIM2_ARRPreloadConfig(ENABLE); TIM2_Cmd(ENABLE); and the same result happens here, all the configuration registers seem to get written appropriately except for CCMR1 and CCMR2. Any input at all would be helpful, thank you in advance!! |
|
相关推荐
2个回答
|
|
|
看起来你正在使用CCMR1&的错误地址CCMR2
根据数据表(DM00024550.pdf),CCMR1位于0x5307&amp; CCMR2位于0x5308。 0x5305是SR2&amp; EGR5306是EGR 我不使用硬件库(或003 - 甚至不知道有一个)所以我的''stm8s.h''的副本很旧,所以我无法查看最新版本使用的地址。 我的副本是 - * @version V1.1.0 * @date 02/27/2009 注意在TIM2的定义中有一个#ifdef STM8S103 您应该检查是否有适用于003的版本 typedef struct TIM2_struct { vu8 CR1; / *&LT!;控制寄存器1 * / #if定义了STM8S103 vu8 RESERVED1; / *&LT!;保留登记册* / vu8 RESERVED2; / *&LT!;保留登记册* / #万一 vu8 IER; / *&LT!;中断使能寄存器* / vu8 SR1; / *&LT!;状态寄存器1 * / vu8 SR2; / *&LT!;状态寄存器2 * / vu8 EGR; / *&LT!;事件生成注册* / vu8 CCMR1; / *&LT!; CC模式寄存器1 * / vu8 CCMR2; / *&LT!; CC模式寄存器2 * / vu8 CCMR3; / *&LT!; CC模式寄存器3 * / vu8 CCER1; / *&LT!; CC启用寄存器1 * / vu8 CCER2; / *&LT!; CC启用寄存器2 * / vu8 CNTRH; / *&LT!;反高* / vu8 CNTRL; / *&LT!;反低* / vu8 PSCR; / *&LT!;预分频器寄存器* / vu8 ARRH; / *&LT!;自动重载寄存器高* / vu8 ARRL; / *&LT!;自动重载寄存器低* / vu8 CCR1H; / *&LT!;捕获/比较寄存器1高* / vu8 CCR1L; / *&LT!;捕获/比较寄存器1低* / vu8 CCR2H; / *&LT!;捕获/比较寄存器2高* / vu8 CCR2L; / *&LT!;捕获/比较寄存器2低* / vu8 CCR3H; / *&LT!;捕获/比较寄存器3高* / vu8 CCR3L; / *&LT!;捕获/比较寄存器3低* / } TIM2_TypeDef; 玩的开心! 以上来自于谷歌翻译 以下为原文 It looks like you're using the wrong addresses for CCMR1 & CCMR2 according to the datasheet (DM00024550.pdf) CCMR1 is at 0x5307 & CCMR2 is at 0x5308. 0x5305 is SR2 & 0x5306 is the EGR I don't use the hardware library (or the 003 - didn't even know there was one) so my copy of ''stm8s.h'' is pretty old so I can't check to see what addresses the latest version uses. My copy is - * @version V1.1.0 * @date 02/27/2009 Note in the definition of TIM2 there is a #ifdef STM8S103 You should check to see if there's a version available that accomodates the 003 typedef struct TIM2_struct { vu8 CR1; /*!< control register 1 */ #if defined STM8S103 vu8 RESERVED1; /*!< Reserved register */ vu8 RESERVED2; /*!< Reserved register */ #endif vu8 IER; /*!< interrupt enable register */ vu8 SR1; /*!< status register 1 */ vu8 SR2; /*!< status register 2 */ vu8 EGR; /*!< event generation register */ vu8 CCMR1; /*!< CC mode register 1 */ vu8 CCMR2; /*!< CC mode register 2 */ vu8 CCMR3; /*!< CC mode register 3 */ vu8 CCER1; /*!< CC enable register 1 */ vu8 CCER2; /*!< CC enable register 2 */ vu8 CNTRH; /*!< counter high */ vu8 CNTRL; /*!< counter low */ vu8 PSCR; /*!< prescaler register */ vu8 ARRH; /*!< auto-reload register high */ vu8 ARRL; /*!< auto-reload register low */ vu8 CCR1H; /*!< capture/compare register 1 high */ vu8 CCR1L; /*!< capture/compare register 1 low */ vu8 CCR2H; /*!< capture/compare register 2 high */ vu8 CCR2L; /*!< capture/compare register 2 low */ vu8 CCR3H; /*!< capture/compare register 3 high */ vu8 CCR3L; /*!< capture/compare register 3 low */ } TIM2_TypeDef; Have fun! |
|
|
|
|
|
谢谢,你说错了地址是正确的。原来我的stm8s.h让我配置了STM8S208而不是103.这反过来又没有添加我需要的两个额外的保留寄存器。因此,定时器2,3,5中的所有寄存器都被2偏移。这就是为什么硬件库也无法工作的原因。我自己确信CCMR1的地址是0x5305,因为参考手册说偏移量可能是0x05或0x07,但并没有真正说明原因,参考手册中的链接可以帮助您选择您需要的那个对我来说是坏的。
无论如何,谢谢你的帮助。这教会我将来要更加小心。这是一个奇迹,我设法让timer1编码器工作有错误的MCU定义。 以上来自于谷歌翻译 以下为原文 Thank you, you are right about the wrong addresses. It turns out my stm8s.h had me configured for the STM8S208 instead of the 103. That in turn did not add in the two extra reserved registers i needed. So all of my registers in timers 2,3,5 were offset by 2. That is why the hardware libraries didn't work either. And i had myself convinced the address for CCMR1 was 0x5305 because the reference manual says the offset could be either 0x05 or 0x07, but doesnt really say why, and the link in the reference manual that helps you choose which one you need is broken for me. At any rate, thanks for the help. This teaches me to be more careful in the future. Its a miracle i managed to get timer1 encoder working having the wrong MCU defined. |
|
|
|
|
只有小组成员才能发言,加入小组>>
stm32mp157的异核通信的rpmsg_sdb的m4固件和a7驱动该如何编写?
1453 浏览 0 评论
stm32f103用freertos对一个采样率为1kHz的传感器,进行采样,数据出差
1502 浏览 0 评论
请教:在使用UDE STK时,单片机使用SPC560D30L1,在配置文件怎么设置或选择?里面只有SPC560D40的选项
3649 浏览 1 评论
3842 浏览 1 评论
请问是否有通过UART连接的两个微处理器之间实现双向值交换的方法?
2461 浏览 1 评论
STM32H7打开DCache后,出现了串口接收信息为空的现象,是哪里出了问题?
727浏览 5评论
用NANO STM32F103RBT6的开发板烧录不了是哪里出了问题?
661浏览 5评论
710浏览 5评论
外部中断触发类型为双边沿触发,进入中断回调后有什么办法判断该边沿是上升沿还是下降沿?
941浏览 5评论
STM32L071CBT6低温环境下无法正常工作是什么原因引起的?
745浏览 5评论
/9
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-12-2 06:55 , Processed in 0.778468 second(s), Total 76, Slave 59 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191

淘帖
304