0

I write a program to display some number on 7seg dispaly by port 0. And i have a problem, if i want to do it with port for exmaple 2 i works great. By when i use port 0 it does not work. What i do wrong. Here is my code:

#include <REGX52.H>

char wyswietlacz[2]={0x06, 0x06};
void wyswietlanie(){

P0=0x30 ;
P2_0=0x01;
P2_1=0x00;
P2_0=0;
P2_1=0;
P0=0x30 ;
P2_0=0;
P2_1=1;
P2_0=0;
P2_1=0;
}
void main(void){
  while(1){
    wyswietlanie();
 }
}

And how it works: enter image description here

AdamKa
  • 41
  • 5

1 Answers1

0

Port 0 has open drain outputs, see its data sheet. That means that each pin can only sink current, but not source. How you did it, only "low" can be output, but not "high".

You can try to use pull-up resistors, which are needed if you use the port as general purpose I/O. However, I would not recommend this because the raising edge of a low-to-high change might be too slow. And it raises the power consumption.

the busybee
  • 10,755
  • 3
  • 13
  • 30