8 years, 2 months ago.

mbed HRM1017のPortOutの使い方について

PortOutでp0〜p7をデータバスとして一気に変更しようとしていますが、 アクセスを行うと他のポートが勝手に変更されてしまう現象で悩んでします。 使い方、誤り等ご指摘いただけますと幸いです。

以下のソースで動かしています。 内容としまして、 1.DigitalOutでp19をHighに設定 2.PortOutでp0〜p7を一斉に0(ゼロ)設定 3.DigitalOutでp19をHighに設定 各操作の後にはpc.printf()を行い3秒空けています。 この状態とp19出力をオシロで観測すると、2.のPortOutを実行した時に、 p19がLowになってしまいます。

  1. include "mbed.h"
  2. include "BLEDevice.h"

Serial pc(USBTX, USBRX); tx, rx for DEBUG I2C i2c0(p22, p20); sda0, scl0

DigitalOut testout(p19); TEST out DigitalOut led(p18); access LED DigitalIn sw1(p16); next SW1 DigitalIn sw2(p17); next SW2

  1. define DBUS_MASK 0x000000FF PortOut dbus(Port0, DBUS_MASK); data bus

/////////////// int main(void) { testout = 1; H output p19 pc.printf("p19 = H output.\r\n"); wait(3.0);

dbus = 0x00000000; Data Bus write 0x00 pc.printf("data = 0x00 output.\r\n"); wait(3.0);

testout = 1; H output p19 pc.printf("p19 = H output.\r\n"); wait(3.0);

for(;;){ wait(0.5); } }

Question relating to:

Switch Science is one of the open source hardware retailers in Japan. We are manufacturing our own products.
Be the first to answer this question.