h_12345 发表于 2011-3-2 14:21:05

stm8s的PA端口复用问题?

现在用stm8s103f3,如何把PA1,PA2口输出口?
用的是内部时钟,程序如下
    CLK_CKDIVR = 0;          /* 01: fHSI= fHSI RC output. */
    CLK_HSITRIMR =15;
  CLK_ICKR=3;

发表于 2011-3-2 15:22:17

RE:stm8s的PA端口复用问题?

1、通过设置PA_CR1x来控制PAx口的输入或者输出模式1(悬空/上拉、开漏/上拉),PA_CR2x来控制PAx口控制输入或输出模式2。
2、通过设置PA_DDRx来设置PAx口的方向
3、通过Px_ODR来输出高低电平或者Px_IDR来读取输入电平。

h_12345 发表于 2011-3-2 16:14:10

回复:stm8s的PA端口复用问题?

PA_DDR=0x6;//PA1,PA2输出
PA_CR1=0x06;
PA_ODR=0x06;//输出高
测试结果:PA_IDR=0;
电压:0V
 

h_12345 发表于 2011-3-2 16:15:33

RE:stm8s的PA端口复用问题?

这个是晶振复用的问题,不像其它IO口,不知要怎么设置?

发表于 2011-3-2 17:22:56

RE:stm8s的PA端口复用问题?

When the MCU is in Halt/Active-halt mode, PA1 is automatically configured in input weak pull up and cannot be used for waking up the device. In this mode, the output state of PA1 is not driven. It is recommended to use PA1 only in input mode if Halt/Active-halt is used in the application.
上述是PA1的注意事项,你可以用上述代码测试一下PA的其他口,如果可以使用。你在配置时钟时增加先写:CLK_ECKR_HSEEN=0,试一下,能不能操作PA1和PA2。

h_12345 发表于 2011-4-22 12:01:55

回复:stm8s的PA端口复用问题?

问题已解决,重新烧写option就行了。
页: [1]
查看完整版本: stm8s的PA端口复用问题?