通过 16f84a 对 8255 进行编程

发布于 2024-12-20 14:26:14 字数 1748 浏览 1 评论 0原文

我正在尝试通过 16f84a 写入 8255 ppi(可编程外设接口)的控制字节。 Proteus 一切正常,但我无法在电路上向 8255 写入任何内容。输入从16f84a(PORTB)出来并连接到8255的数据总线。有人说写入8255必须有延迟。我尝试过但没有成功。这是我编写的一个测试程序,用于通过 8255 获取输出。所有端口都设置为输出(A、B、C)。但这不起作用。 proteus 屏幕截图的链接 https://i.sstatic.net/UQbfG.jpg

bsf     PORTA,3                 ; activate 8255's reset pin
            call jDelay

            bcf     PORTA,3                 ; deactivate 8255's reset pin

            movlw   b'00000001'                 ; Control byte for 8255 (B0->D7....B7->D0) /reverse of 10000000 (all set to output)
            movwf   PORTB
            movlw   b'00000011'                 ; mode 11 to write control register and also PortA.3-> 8255.WR (activate with 0 ,WR pin active-low)
            movf PORTA                          ;portA.0->8255.A0&& portA.1->8255.A1

            call    jDelay                      ; Delay to write control byte

            bsf     PORTA,2                     ; Deactive Write pin of 8255 (Active-low , 1 deactivates)

main


    movlw      B'10110110'       ; Digit value for 5
    movwf       PORTB
        movlw b'00000000'       ; mode 00 and activate WR pin
        movwf PORTA             ; write to portA so -> 8255
        call jDelay             ; Delay to write  byte
        bsf     PORTA,2         ; Deactivate 8255's WR pin(active-low)

        Delay                   ;endless loop
        goto Delay

        jDelay                   ; Delay loop
        Loop3               decfsz              COUNT1,1
                        goto Loop3
                            decfsz              COUNT3,1
                        goto Loop3

    return
end

I am trying to write control byte of the 8255 ppi(Programmable Peripheral Interface) through 16f84a. Everything fine with Proteus but I can't write anything to 8255 on my circuit. Inputs get out from 16f84a(PORTB) and connected to the Data bus of 8255. Some said must have an delay to write 8255. I tried but didn't work. Here is a test program I wrote to get output through 8255. all ports are set to output (A,B,C). But it doesn't work.
link for proteus screen shot
https://i.sstatic.net/UQbfG.jpg

bsf     PORTA,3                 ; activate 8255's reset pin
            call jDelay

            bcf     PORTA,3                 ; deactivate 8255's reset pin

            movlw   b'00000001'                 ; Control byte for 8255 (B0->D7....B7->D0) /reverse of 10000000 (all set to output)
            movwf   PORTB
            movlw   b'00000011'                 ; mode 11 to write control register and also PortA.3-> 8255.WR (activate with 0 ,WR pin active-low)
            movf PORTA                          ;portA.0->8255.A0&& portA.1->8255.A1

            call    jDelay                      ; Delay to write control byte

            bsf     PORTA,2                     ; Deactive Write pin of 8255 (Active-low , 1 deactivates)

main


    movlw      B'10110110'       ; Digit value for 5
    movwf       PORTB
        movlw b'00000000'       ; mode 00 and activate WR pin
        movwf PORTA             ; write to portA so -> 8255
        call jDelay             ; Delay to write  byte
        bsf     PORTA,2         ; Deactivate 8255's WR pin(active-low)

        Delay                   ;endless loop
        goto Delay

        jDelay                   ; Delay loop
        Loop3               decfsz              COUNT1,1
                        goto Loop3
                            decfsz              COUNT3,1
                        goto Loop3

    return
end

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

锦欢 2024-12-27 14:26:14

最有可能的是,您烧毁了 8255。您的电路有效地将 8255 的输出接地短路。您没有给出您所使用的 8255 的确切部件号,但单个端口上所有位的最大输出电流通常约为 4mA总计。数据表上还应注明提供电流限制,必须由外部电路提供。你没有限流。

LED 非常接近接地短路。 8255根本无法驱动它。

断开 LED 并查看 8255 的输出是否仍然工作。如果没有,请更换 8255,并在每个端口输出和 LED 之间使用适当的输出驱动器或至少 330 欧姆的电阻。

Most likely, you blew the 8255. Your circuit effectively shorts the 8255's outputs to ground. You don't give the exact part number of the 8255 you are using, but they typically have a maximum output current of around 4mA total for all bits on a single port. There should also be a note on the datasheet that no current-limiting is provided and must be provided by the external circuitry. You have no current-limiting.

An LED is pretty close to a short to ground. The 8255 simply cannot drive it.

Disconnect the LED and see if the 8255's outputs still work. If not, replace the 8255 and use a proper output driver or a least a 330 ohm resistor between each port output and the LED.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文