0
\$\begingroup\$

I'm trying to send The PORTB to the serial port and receiving the data on pickit2 UART mode..

void main()
{
  TRISB = 0xFF;
  PORTB = 0;
  UART1_Init(9600); // Initialize UART module at 9600bps
  Delay_ms(100); // Wait for UART module to stabilize
  while (1)
  { // Endless loop
    UART1_Write(PORTB); // and send data via UART
    Delay_ms(500);
  }
}

I'm using MikroC pro. and the problem is I'm not getting proper data.

I've connected pullup resistors to each pin of PORTB and all i get is

RX: E0

which means only RB5, RB6, and RB7 are pulled up rest pins are low.

also noticed if i try to pull down any pin of portb then only these pins cause the value to change. any ideas what might be wrong?

\$\endgroup\$
  • 1
    \$\begingroup\$ Just wondering Why it got downvoted? \$\endgroup\$ – Suraj Bhawal Apr 7 '15 at 6:41
  • \$\begingroup\$ You'll have to deal with it my friend, this is nothing. No matter how much perfect your question is, it will get downvoted. \$\endgroup\$ – 3bdalla Apr 7 '15 at 9:59
  • \$\begingroup\$ @3bdalla Yeah! but the question is why? . No matter how much perfect your question is, it will get downvoted why is that? \$\endgroup\$ – Suraj Bhawal Apr 7 '15 at 10:31
  • \$\begingroup\$ When I question that issue I get downvotes. Downvoting users always downvotes without any further explanation to help the user asked the question make his question more clear and follow the community standards. They have that excuse of large number of question or something like that, well I say it again If you don't explain your downvote, DO NOT DOWNVOTE! If anyone disagree with this tell me which letter of my comment did not understand because I will not explain ;) \$\endgroup\$ – 3bdalla Apr 7 '15 at 13:48
3
\$\begingroup\$

According to the datasheet, on start-up RB4:RB0 are configured as analog inputs and will read as zero.

You need to make them digital inputs instead during initialisation, for example:

ADCON1 = 0x0E;

Alternatively, you can clear the PBADEN bit in the CONFIG3H register by changing your configuration settings.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.