你好,
我正在使用带有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 configura
ting 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