View previous topic :: View next topic |
Author |
Message |
d_nikolaos
Joined: 13 Oct 2008 Posts: 17 Location: Greece,Macedonia,Thessaloniki,Kalamaria
|
Input, Output at the same port(pin) |
Posted: Mon Nov 03, 2008 11:42 am |
|
|
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? |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Nov 03, 2008 12:31 pm |
|
|
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. |
|
![](templates/subSilver/images/spacer.gif) |
d_nikolaos
Joined: 13 Oct 2008 Posts: 17 Location: Greece,Macedonia,Thessaloniki,Kalamaria
|
|
Posted: Mon Nov 03, 2008 12:52 pm |
|
|
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 |
|
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Nov 03, 2008 12:57 pm |
|
|
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). |
|
![](templates/subSilver/images/spacer.gif) |
d_nikolaos
Joined: 13 Oct 2008 Posts: 17 Location: Greece,Macedonia,Thessaloniki,Kalamaria
|
|
Posted: Mon Nov 03, 2008 1:07 pm |
|
|
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? |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Nov 03, 2008 1:13 pm |
|
|
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. |
|
![](templates/subSilver/images/spacer.gif) |
d_nikolaos
Joined: 13 Oct 2008 Posts: 17 Location: Greece,Macedonia,Thessaloniki,Kalamaria
|
|
Posted: Mon Nov 03, 2008 1:24 pm |
|
|
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. |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Nov 03, 2008 1:28 pm |
|
|
Post the manufacturer and part numbers of these devices. |
|
![](templates/subSilver/images/spacer.gif) |
d_nikolaos
Joined: 13 Oct 2008 Posts: 17 Location: Greece,Macedonia,Thessaloniki,Kalamaria
|
|
Posted: Mon Nov 03, 2008 1:30 pm |
|
|
The manufacturer is maxim and the device is max1312. |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Nov 03, 2008 1:53 pm |
|
|
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 ? |
|
![](templates/subSilver/images/spacer.gif) |
d_nikolaos
Joined: 13 Oct 2008 Posts: 17 Location: Greece,Macedonia,Thessaloniki,Kalamaria
|
|
Posted: Mon Nov 03, 2008 2:19 pm |
|
|
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? |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Nov 03, 2008 2:28 pm |
|
|
What is the overall purpose of the project ? What signals do you need
to sample in 2 us ? Why ? |
|
![](templates/subSilver/images/spacer.gif) |
d_nikolaos
Joined: 13 Oct 2008 Posts: 17 Location: Greece,Macedonia,Thessaloniki,Kalamaria
|
|
Posted: Mon Nov 03, 2008 2:35 pm |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
![](templates/subSilver/images/spacer.gif) |
d_nikolaos
Joined: 13 Oct 2008 Posts: 17 Location: Greece,Macedonia,Thessaloniki,Kalamaria
|
|
Posted: Mon Nov 03, 2008 3:06 pm |
|
|
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? |
|
![](templates/subSilver/images/spacer.gif) |
|