ST意法半导体
直播中

卢原继

7年用户 232经验值
私信 关注
[问答]

使用STM8L151C8怎么激活DAC2

你好,


我正在使用带有48个引脚的STM8L151C8。
对于PF0上的默认DAC1输出(工作正常)我想访问第二个DAC输出,我希望在PB6上输出。 Ref手册说这可以通过配置开关来实现,参见Doc ID 15226 Rev 10第219/575页。

在我的代码中,我有关于DAC2的以下几行:

#define DAC2 PIO_Pin_6 // DAC通道2


#define PB_DDR_Init GPIO_DDR_RESET_VALUE //与DAC2无关
#define PB_ODR_Init GPIO_ODR_RESET_VALUE //与DAC2无关
#define PB_CR1_Init GPIO_CR1_RESET_VALUE | DAC2
#define PB_CR2_Init GPIO_CR1_RESET_VALUE //清除所有位



GPIOB-> ODR = PB_ODR_Init;
GPIOB-> DDR = PB_DDR_Init;
GPIOB-> CR1 = PB_CR1_Init;
GPIOB-> CR2 = PB_CR2_Init;


RI-> IOSR1 = 0x80; //应该是PB6的正确选择


DAC-> CH1CR1 = DAC_CR1_RESET_VALUE | DAC_CR1_EN; / * DAC1启用,缓冲打开* /
DAC-> CH2CR1 = DAC_CR1_RESET_VALUE | DAC_CR1_EN; / * DAC2启用,Buffer on * /


DAC-> CH2RDHRH =(uint8_t)(0);
DAC-> CH2RDHRL =(uint8_t)(0);
// DAC-> DCH2RDHRH = 0; // DAC2设置为0
// DAC-> DCH2RDHRL = 0; // DAC2设置为0

我试过最后两行。结果总是在PB6处是3.2伏的电压。我的程序没有重置为某个值或零。

我的错是什么?

先谢谢你。

迪特

以上来自于谷歌翻译


以下为原文




Hello,


I am working with STM8L151C8 with 48 pins.
To my default DAC1 output on PF0 (which works fine) I want to access to the second DAC output, which I want to have on PB6. The Ref manual says that this is possible by configurating the switches, see Doc ID 15226 Rev 10 page 219/575.

In my code I have the following lines in respect to DAC2:

#define DAC2 PIO_Pin_6 //DAC channel 2


#define PB_DDR_Init GPIO_DDR_RESET_VALUE  // not relevant for DAC2
#define PB_ODR_Init GPIO_ODR_RESET_VALUE  // not relevant for DAC2
#define PB_CR1_Init GPIO_CR1_RESET_VALUE | DAC2
#define PB_CR2_Init GPIO_CR1_RESET_VALUE  //clear all bits  
   
   
   
   GPIOB->ODR = PB_ODR_Init;
   GPIOB->DDR = PB_DDR_Init;
   GPIOB->CR1 = PB_CR1_Init;
   GPIOB->CR2 = PB_CR2_Init;


RI->IOSR1 = 0x80;  //should be the right one for PB6


DAC->CH1CR1 = DAC_CR1_RESET_VALUE | DAC_CR1_EN; /* DAC1 enable, Buffer on */
DAC->CH2CR1 = DAC_CR1_RESET_VALUE | DAC_CR1_EN; /* DAC2 enable, Buffer on */


     DAC->CH2RDHRH = (uint8_t) (0);
     DAC->CH2RDHRL = (uint8_t) (0);
//    DAC->DCH2RDHRH = 0;  //DAC2 setting to 0
//    DAC->DCH2RDHRL = 0;  //DAC2 setting to 0

I tried both for the last two lines. The result is always, that at PB6 is a voltage of 3.2 Volts. My program does not reset to a certain value or zero.

What is my fault here?

Thank you in advance.

Dieter

回帖(1)

h1654155275.5950

2018-9-21 17:10:22
你好Dieter
我在同一个微处理器上遇到了与DAC2相同的问题。
你修复过你的问题吗?我不明白为什么有多少问题处于暂停状态,DAC 2是一个真正的问题,而DAC 1非常容易配置。
所以在我的询问中,为了激活DAC2到PB4的路由,我设置了AnalogueSwitch_4和RI_IO_SWITCH 15
(我使用Cosmic C编译器)如果你有任何信息,它会很棒。
问候
布鲁诺维尔特

以上来自于谷歌翻译


以下为原文




Hello Dieter
I have the same problem with the DAC2 on the same micro processor.
Do you have fixed your problem ? I do not understand why much questions are in suspend, the DAC 2 is a real problem whereas the DAC 1 is quite easy to configure.
So in my enquiry, in order to activate the routing of DAC2 to PB4, I set the AnalogueSwitch_4 and RI_IO_SWITCH 15
(I work with the Cosmic C compiler) if you have any information, it will be great.
Regards
Bruno VELUT
举报

更多回帖

发帖
×
20
完善资料,
赚取积分