Output Issues with individual Port addressing
Posted: Tue Jan 28, 2020 6:40 pm
Hi
I was getting strange results within a program so decided to investigate further, briefly hardware wasn't doing as it should.
I created a breakout board and connected it to Port C of an EB-006-09 fitted with a 16f877a and in Flowcode using 5mm_Led Outputs created the following which is mimicked in hardware.
Port C0 = Clip-3 (red led)
Port C1 = Clip-2 (orange led)
Port C2 = Clip-1 (green led)
My program first switches off all on Port C, then it loops three times flashing all led's on/off. This is fine. It then illuminates Clip-1, waits, illuminates Clip-2, waits and then illuminates Clip-3. So basically after flashing three times it illuminates each led in turn and I end up with all three led's on.
Perfect in simulation and in hardware.
Program Test-1 is my program. In this program you can see that I am outputting exactly which Ports I want On by sending the corresponding value to the Port (e.g. 4 / 6 / 7 which sets C2 / C2 and C1 / C2, C1 and C0 = On respectively).
However if I then change my output method to addressing each bit individually I get funny results.
Please see Program Test-2 In this program I set each bit of Port-C individually.
After flashing OK I then send a value of "1" to Single Bit 2, then to Single Bit 1 and finally to Single Bit 0.
This should have the same results as Test-1 but this time after I send "1" to Single Bit 1, as well as illuminating the LED attached to Bit 1 it switches Bit 2 Off. When I send "1" to Single Bit 0 it illuminates alongside Bit 1 but Bit 2 stays Off.
I then tried using the Call Component macros.
Please see Test-3 In this I switch Led-Clips 1 to 3 On individually but I get the same results as in Test-2. When I switch on Led Clip-2, it comes On but switches Clip-1 Off. When I then switch on Clip-3 it comes On alongside Clip-2 but Clip-1 remains Off.
I see this in hardware so thought perhaps the chip was a bit iffy however I tried the above in three different chips with the exact same results. If I output anything other than the exact Port settings I need, then things go astray.
Incidentally if I send 255 and use masking (2/1/0) everything is OK.
Anybody got any idea of what I'm doing wrong?
Regards
I was getting strange results within a program so decided to investigate further, briefly hardware wasn't doing as it should.
I created a breakout board and connected it to Port C of an EB-006-09 fitted with a 16f877a and in Flowcode using 5mm_Led Outputs created the following which is mimicked in hardware.
Port C0 = Clip-3 (red led)
Port C1 = Clip-2 (orange led)
Port C2 = Clip-1 (green led)
My program first switches off all on Port C, then it loops three times flashing all led's on/off. This is fine. It then illuminates Clip-1, waits, illuminates Clip-2, waits and then illuminates Clip-3. So basically after flashing three times it illuminates each led in turn and I end up with all three led's on.
Perfect in simulation and in hardware.
Program Test-1 is my program. In this program you can see that I am outputting exactly which Ports I want On by sending the corresponding value to the Port (e.g. 4 / 6 / 7 which sets C2 / C2 and C1 / C2, C1 and C0 = On respectively).
However if I then change my output method to addressing each bit individually I get funny results.
Please see Program Test-2 In this program I set each bit of Port-C individually.
After flashing OK I then send a value of "1" to Single Bit 2, then to Single Bit 1 and finally to Single Bit 0.
This should have the same results as Test-1 but this time after I send "1" to Single Bit 1, as well as illuminating the LED attached to Bit 1 it switches Bit 2 Off. When I send "1" to Single Bit 0 it illuminates alongside Bit 1 but Bit 2 stays Off.
I then tried using the Call Component macros.
Please see Test-3 In this I switch Led-Clips 1 to 3 On individually but I get the same results as in Test-2. When I switch on Led Clip-2, it comes On but switches Clip-1 Off. When I then switch on Clip-3 it comes On alongside Clip-2 but Clip-1 remains Off.
I see this in hardware so thought perhaps the chip was a bit iffy however I tried the above in three different chips with the exact same results. If I output anything other than the exact Port settings I need, then things go astray.
Incidentally if I send 255 and use masking (2/1/0) everything is OK.
Anybody got any idea of what I'm doing wrong?
Regards