完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
电子发烧友论坛|
你好,
我正在使用STM8AL Discovery板。我试图使用ST驱动程序使ADC工作。当我初始化代码时,ADC寄存器中没有显示任何内容。下面是我的初始化代码: / * --- ADC --- * / //初始化IO GPIO_Init(GPIOA,GPIO_Pin_6,GPIO_Mode_In_FL_No_IT); //初始化ADC ADC_Init(ADC1,ADC_ConversionMode_Single,ADC_Resolution_12Bit,ADC_Prescaler_2); ADC_SamplingTimeConfig(ADC1,ADC_Group_SlowChannels,ADC_SamplingTime_96Cycles); //启用ADC1 ADC_Cmd(ADC1,ENABLE); //启用ADC1通道0 ADC_ChannelCmd(ADC1,ADC_Channel_0,ENABLE); //启用ADC中断 ADC_ITConfig(ADC1,ADC_IT_EOC,ENABLE); 然而,没有一个ADC寄存器是用我的初始化编写的。 有谁知道是什么原因引起的? 问候, 道格 #adc#stm8-discovery 以上来自于谷歌翻译 以下为原文 Hello, I'm using the STM8AL Discovery board. Im trying to get the ADC working using the ST drivers. When I initialize the code Nothing shows up in the ADC registers. Below is my initialization code: /* --- ADC --- */ // Initialize the IO GPIO_Init(GPIOA,GPIO_Pin_6,GPIO_Mode_In_FL_No_IT); // Initialize the ADC ADC_Init(ADC1, ADC_ConversionMode_Single, ADC_Resolution_12Bit, ADC_Prescaler_2); ADC_SamplingTimeConfig(ADC1, ADC_Group_SlowChannels, ADC_SamplingTime_96Cycles);// Enable ADC1 ADC_Cmd(ADC1, ENABLE); // Enable ADC1 Channels 0 ADC_ChannelCmd(ADC1, ADC_Channel_0, ENABLE); // Enable ADC Interrupt ADC_ITConfig(ADC1, ADC_IT_EOC, ENABLE); Yet none of the ADC registers are getting written with my Initialization. Does anyone know what could be causing this? Regards, Doug #adc #stm8-discovery |
|
相关推荐
6个回答
|
|
|
你好!我刚刚开始了解STM8L系列,我正在学习汇编编程,
但我想帮忙。您应该检查ADC_SQR1寄存器中的DMA_OFF位是否为1。 这可能会导致您在ADC结果寄存器中看不到任何内容。当然,某些东西必须由实际转换触发。 Softver必须将'1'写入寄存器ADC_CR1中的START位, 或选择另一个触发源。 问候:彼得 必须是'1'。这可能会导致您在ADC结果寄存器中看不到任何内容。当然,某些东西必须由实际转换触发。将寄存器ADC_CR1的START位写入'1'或选择另一个触发源。 以上来自于谷歌翻译 以下为原文 Hello! I'm just getting to know the STM8L family and I'm learning assembler programming, but I'm trying to help. You should check that the DMA_OFF bit in the ADC_SQR1 register should be '1'. This may cause you to see nothing in the ADC result registers. Of course, something has to be triggered by the actual conversion. Softver have to write '1' to the START bit in the register ADC_CR1, or select another trigger source. Regards: Peter must be '1'. This may cause you to see nothing in the ADC result registers. Of course, something has to be triggered by the actual conversion. Write the START bit of the register ADC_CR1 in '1' or select another trigger source. |
|
|
|
|
|
谢谢Peter的回复。我的后续代码尝试设置DMA位。问题是我无法写入ADC寄存器。无法设置预分频器。无法打开AD。无法启动转换。我试着设置的任何一点都没有设置。我在2个不同的stm8a-discovery板上尝试了这个,但都没有用。就像ADC寄存器被锁定一样。
问候, 以上来自于谷歌翻译 以下为原文 Thank you Peter for the reply. My follow up code attempts to set the DMA bit. The problem is I cannot write to the ADC registers. Cannot set the prescaler. Cannot turn on the AD. Cannot start the conversion. Any bit i try and set does not get set. I have tried this on 2 different stm8a-discovery boards and neither works. Its as if the ADC registers are locked. Regards, |
|
|
|
|
|
你好道格,
请在下面找到最小代码,该代码允许配置一个ADC通道并在循环中进行AD转换。您可以直接在STM8 Discovery工具包上进行测试。我的代码不使用EOC中断来指示转换结束,而是使用EOC标志的检查。 为了防止它有用,我还附上了一个完整的STVD IDE项目。 Szymon 以上来自于谷歌翻译 以下为原文 Hello Doug, Please find below the minimum code, which allows to configure one ADC channel and make an AD conversions in the loop. You can test it directly on STM8 Discovery kit. My code doesn't use EOC interrupt to indicate conversion end, but instead I use checking of EOC flag. Just in case it would be helpful, I attach also a complete project for STVD IDE. Szymon |
|
|
|
|
|
谢谢你回复Szymon。这与我创建的代码几乎相同。问题是寄存器不会写init值。它不仅仅是数据寄存器没有更新。他们都不是。没有CR寄存器。没有。所以代码不起作用,因为寄存器没有写入。
我正在使用STM8AL Discovery板。 LCD连接能不能解决我的问题。 以上来自于谷歌翻译 以下为原文 Thank you for the reply Szymon. That is near the same code as I created. The problem is the registers will not write the init values. Its not just the data register not updating. None of them are. None of the CR registers. Nothing. So the code does not work because the registers are not getting written. I am using the STM8AL Discovery board. Could the LCD connections be whats giving me my issue. |
|
|
|
|
|
转至stm8_it.c文件并搜索您正在使用的ADC1的中断服务程序(ISR)。在该服务例程中使用函数GETADC1CONVERSIONresult()。此外,当您使用单一模式的会话时,ADC将只提供一个值....更好地使用连续的会话模式。
希望它对你有所帮助。 以上来自于谷歌翻译 以下为原文 Go to stm8_it.c file and search for interrupt service routine(ISR) of ADC1 that u are using. In that service routine use function GETADC1CONVERSIONresult() . Also as u are using single mode of conversation ADC will give only one value....better to use continuous mode of conversation. Hope it will be helpful for u. |
|
|
|
|
|
我非常感谢所有评论。但我认为你们误解了发生的事情。让我试着解释一下:
ADC_Init(ADC1,ADC_ConversionMode_Single,ADC_Resolution_12Bit,ADC_Prescaler_2); 我在初始化时调用上面的函数。 CR1,2或3寄存器不会更改值。它不接受我的初始化请求。 ADC_Cmd(ADC1,ENABLE); 我在初始化时调用上面的函数。没有寄存器得到更新。 它的作用就像ADC被锁定一样,不允许任何配置。 以上来自于谷歌翻译 以下为原文 I really appreciate all of the comments. But I think you guys are misunderstanding whats happening. Let me try and explain it like this: ADC_Init(ADC1, ADC_ConversionMode_Single, ADC_Resolution_12Bit, ADC_Prescaler_2); I call the above function in my initialization. The CR1,2, or 3 registers DO NOT change values. It is not accepting my initialization request. ADC_Cmd(ADC1, ENABLE); I call the above function in my initialization. None of the registers get updated. It is acting as if the ADC is locked and will not allow any configuration. |
|
|
|
|
只有小组成员才能发言,加入小组>>
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的开发板烧录不了是哪里出了问题?
663浏览 5评论
710浏览 5评论
外部中断触发类型为双边沿触发,进入中断回调后有什么办法判断该边沿是上升沿还是下降沿?
941浏览 5评论
STM32L071CBT6低温环境下无法正常工作是什么原因引起的?
745浏览 5评论
/9
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-12-2 09:50 , Processed in 0.880741 second(s), Total 84, Slave 67 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191

淘帖
490