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 CCS Technical Support

Input, Output at the same port(pin)
Goto page 1, 2  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
d_nikolaos



Joined: 13 Oct 2008
Posts: 17
Location: Greece,Macedonia,Thessaloniki,Kalamaria

View user's profile Send private message

Input, Output at the same port(pin)
PostPosted: Mon Nov 03, 2008 11:42 am     Reply with quote

I want to use the same pins of a port as input and output.
My program is something like this:
Code:
void main() {
set_tris_a(0x00);

if (value<=100){
   set_tris_a(0x1f);
   delay_ms(100);
   take=PORTA & 0x0f;
  }

if(value>=100){
   set_tris_a(0x00);
   delay_ms(100);
   output_high(PIN_A0);
   output_high(PIN_A1);
  }
}

and it doesn't work. Is there anything wrong?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Nov 03, 2008 12:31 pm     Reply with quote

1. Describe the external circuit connected to Port A.

2. Explain the purpose of your program. What do you want it to do ?

3. Post your PIC.

4. Post your compiler version.

5. Post the #fuses and #use delay statements.
d_nikolaos



Joined: 13 Oct 2008
Posts: 17
Location: Greece,Macedonia,Thessaloniki,Kalamaria

View user's profile Send private message

PostPosted: Mon Nov 03, 2008 12:52 pm     Reply with quote

1. With a wire I connect Pin A0 and A1 to a led or to a switch.

2. I want first to set a device and then take some results from the same pins of the same device.

3. My pic is 16F877.

4. I don't remember the version but I think is the latest.

5. my fuses and delay statements:
Code:
 # fuses XT,NOWDT,PUT,NOBROWNOUT,NOMCLR,NOLVP     
       #use delay (clock=2000000)
       #byte PORTA=0x05
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Nov 03, 2008 12:57 pm     Reply with quote

Quote:
# fuses XT,NOWDT,PUT,NOBROWNOUT,NOMCLR,NOLVP
#use delay (clock=2000000)
#byte PORTA=0x05

Are you really using a 2 MHz clock ? Or is it 20 MHz ?
If it is 20 MHz, then you must use the HS fuse (not XT).
d_nikolaos



Joined: 13 Oct 2008
Posts: 17
Location: Greece,Macedonia,Thessaloniki,Kalamaria

View user's profile Send private message

PostPosted: Mon Nov 03, 2008 1:07 pm     Reply with quote

Sorry for my mistake. My fuses are:
#fuses HS, NOWDT,PUT,NOBROWNOUT,NOLVP
and my crystal is 20 MHz.
My compiler version is 4,057.

Can I use #use fast_IO?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Nov 03, 2008 1:13 pm     Reply with quote

Yes you can use fast i/o.

Quote:
1. With a wire I connect Pin A0 and A1 to a led or to a switch.

If the switch is set to connect ground to pins A0 or A1, you will not be
able to drive the pin to a high level to turn on the LED. My advice is to
use separate pins for the switches and the LEDs. It's easier.
d_nikolaos



Joined: 13 Oct 2008
Posts: 17
Location: Greece,Macedonia,Thessaloniki,Kalamaria

View user's profile Send private message

PostPosted: Mon Nov 03, 2008 1:24 pm     Reply with quote

The leds and switch were examples.
In fact what I want to do is from the same pins(A0......A7) to sent in another device some bits and then the other device sent back some other bits at the same pins.


Sorry about my English.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Nov 03, 2008 1:28 pm     Reply with quote

Post the manufacturer and part numbers of these devices.
d_nikolaos



Joined: 13 Oct 2008
Posts: 17
Location: Greece,Macedonia,Thessaloniki,Kalamaria

View user's profile Send private message

PostPosted: Mon Nov 03, 2008 1:30 pm     Reply with quote

The manufacturer is maxim and the device is max1312.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Nov 03, 2008 1:53 pm     Reply with quote

You don't need to talk about switches and LEDs and i/o.
You need a driver for the MAX1312. A "driver" is a software program
that talks to the hardware on the chip. It provides an easy-to-use
software interface consisting of functions that initialize the chip, and
also allow reading and writing to the chip.

The MAX1312 has a large number of i/o pins and a large number
of control signals. There is no existing sample code on the net
for this chip or any similar chips listed on the MAX1312 data sheet.
Do really need to use this chip ?
d_nikolaos



Joined: 13 Oct 2008
Posts: 17
Location: Greece,Macedonia,Thessaloniki,Kalamaria

View user's profile Send private message

PostPosted: Mon Nov 03, 2008 2:19 pm     Reply with quote

I need something similar to this. I want to do analog to digital
conversion of 8 channels and the max1312 do exactly this and
very quick. Do you have anything else to propose?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Nov 03, 2008 2:28 pm     Reply with quote

What is the overall purpose of the project ? What signals do you need
to sample in 2 us ? Why ?
d_nikolaos



Joined: 13 Oct 2008
Posts: 17
Location: Greece,Macedonia,Thessaloniki,Kalamaria

View user's profile Send private message

PostPosted: Mon Nov 03, 2008 2:35 pm     Reply with quote

I want to measure a three phase current and voltage and sent them to a PC.
I think to convert these signals to digital and then send them to a PC through the pic
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Nov 03, 2008 2:58 pm     Reply with quote

Maybe one of the chips on this page would be better:
http://www.microchip.com/stellent//groups/analog_sg/documents/devicedoc/en024930.pdf

Also look at this development board:
http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1406&dDocName=en520559
d_nikolaos



Joined: 13 Oct 2008
Posts: 17
Location: Greece,Macedonia,Thessaloniki,Kalamaria

View user's profile Send private message

PostPosted: Mon Nov 03, 2008 3:06 pm     Reply with quote

Thanks for your help but these chips are very slow.
Do you know how I can use a pin once for input and once for output?
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
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