CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

PORTB Problem

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
cfernandez



Joined: 18 Oct 2003
Posts: 145

View user's profile Send private message

PORTB Problem
PostPosted: Wed Jul 04, 2007 7:55 pm     Reply with quote

Hi,

I use a 18F4620 25Mhz, and I need use the PortB.0 to PortB.4 for digital input. In this pins I connect a Magnetic Card Reader, in the pin 0 connect the card present, this is high when not is a card, and low when exist a card. The problem is that the pin 0 and 1 not is possible to get the 0 or 1 value from the mag. card reader, the other pins work fine. If I put the pin 0 or 1 to ground I see that signal change from 1 to 0.

Why cannot work the pin 0 and 1 from port b for detect digital input??. Any can help me.

This is my test code

Code:
#include <18F4620.h>
#fuses HS,NOLVP,NOWDT,NOPROTECT
#use delay(clock=25000000)
#use rs232(baud=115200, xmit=PIN_C6, rcv=PIN_C7)

#use fast_io( B )

void main()
{
   int index;
   int error;

   port_b_pullups( FALSE );
   set_tris_b( 0xFF );
   
   error = 0x00;
   while( 1 )
   {
        index = input_b( );
       
        if ( index != error )
        {
            printf( "%u%u%u%u%u%u%u%u\n\r", bit_test( index, 7 ), bit_test( index, 6 ), bit_test( index, 5 ), bit_test( index, 4 ), bit_test( index, 3 ), bit_test( index, 2 ), bit_test( index, 1 ), bit_test( index, 0 ) );
            error = index;
        }
   }       
}     


Thank you very much!!
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Jul 04, 2007 10:33 pm     Reply with quote

It may need a pull-up resistor. Post a link to the data sheet of the
card reader.
cfernandez



Joined: 18 Oct 2003
Posts: 145

View user's profile Send private message

PostPosted: Thu Jul 05, 2007 1:23 pm     Reply with quote

I am use a Kit from CCS and in this kit connect my reader, the problem is that this kit have a connector for GPIO, but the PIN 0 and 1 from PORT B is use for the Ethernet Chip and I have not the schematic for see this information. CCS send me a email with this.

Thank you very much PCM for your time.

Best Regards,
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group