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

Problem with DS1621 and PIC16F819 and RS-232 communication.

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



Joined: 20 Jul 2006
Posts: 29

View user's profile Send private message Send e-mail MSN Messenger

Problem with DS1621 and PIC16F819 and RS-232 communication.
PostPosted: Sat Dec 09, 2006 10:27 am     Reply with quote

Hi, I have built a system to read temperature using the DS1621 and the PIC16F819. This PIC reads the temperature from the DS1621 through I2C and sends the data to the computer through RS-232. I am using the following code for tests (PIN_B1 and PIN_B4 are the ones used for the I2C communication):

I'm using PCM 3.235 version.

#include <16F819.h>
#device adc=8


#FUSES NOWDT //No Watch Dog Timer
#FUSES HS //High speed Osc (> 4mhz)
#FUSES NOPUT //No Power Up Timer
#FUSES NOMCLR //Master Clear pin used for I/O
#FUSES NOBROWNOUT //No brownout reset
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOCPD //No EE protection
#FUSES NOWRT //Program memory not write protected
#FUSES NODEBUG //No Debug mode for ICD
#FUSES NOPROTECT //Code not protected from reading

#use delay(clock=8000000)
#use rs232(baud=9600,parity=N,xmit=PIN_A3,rcv=PIN_A4,bits=8,stream=TEMP)
#use i2c(Master,sda=PIN_B1,scl=PIN_B4, force_HW)
while(true)
{
fprintf(TEMP,"Iniciando medida... \n\r");
output_high(PIN_B1);
output_high(PIN_B4);
i2c_start();
i2c_write(0x90);
i2c_write(0xac);
i2c_write(3);
i2c_stop();
delay_ms(20);

i2c_start();
i2c_write(0x90);
i2c_write(0xee);
i2c_stop();

delay_ms(800);
i2c_start();
i2c_write(0x90);
i2c_write(0xaa);
i2c_start();
i2c_write(0x91);
data1=i2c_read();
data2=i2c_read(0);
i2c_stop();

fprintf(TEMP,"Temperatura: %c - %d\n\r", data1, data2);
}

This is not the final code. I've built it just to test the communication. I have two problems. The first one is with the RS-232 communication. I use the MAX232N for this purpose. When the PIC is not tied to the VCC, it sends the data to the computer perfectly! (CRAZY...) But when I put the PIC tied to the VCC, then it starts sending parts of what it should send in time intervals that do not correspond to those of the code. Again, when I turn the VCC off (for the PIC) it sends the information perfectly, in the correct time instants. This is one problem... the second one is that it returns (when the PIC is not tied to the VCC) the information: "Temperatura: - -1". That is, data1 does not return any value and data 2 returns "-1". I am going crazy with this. I have already used the same schematic for the RS-232 and I2C communication with other PIC and other slave and it worked fine.
Does someone have any suggestion of what could be happening.
Any information would be of great value.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Dec 10, 2006 4:33 pm     Reply with quote

Quote:
When the PIC is not tied to the VCC, it sends the data to the computer
perfectly! But when I put the PIC tied to the VCC, then it starts sending
parts of what it should send in time intervals that do not correspond to
those of the code. Again, when I turn the VCC off (for the PIC) it sends
the information perfectly, in the correct time instants.

If the PIC runs when the Vdd voltage is removed from it, then it
means the PIC is getting power from an i/o pin (possibly through
a pull-up resistor).

My guess is that you have a problem with your hardware connections.
You may be missing a common ground (Vss) connection between the
chips and the power supply on your board. It will be something like that.
Sherpa Doug
Guest







PostPosted: Sun Dec 10, 2006 5:05 pm     Reply with quote

When the PIC is NOT connected to VCC measure the voltage on the PIC VCC pin and on all of its I/O pins. One or more of the I/O pins will be higher than the VCC pin by a few tenths of a volt, and that pin(s) is providing power to the PIC. Also double check your grounds.
otavio_fisica



Joined: 20 Jul 2006
Posts: 29

View user's profile Send private message Send e-mail MSN Messenger

PostPosted: Mon Dec 11, 2006 12:02 pm     Reply with quote

I've checked which is the I/O the pic is getting voltage from. It's from the pin used as RX. I tried to change the pins in the pic, but nothing different happened. I have also checked all the ground connections and they are perfect. I still do not know what to do... And about the software? Do you think it will work if this first problem is solved?
Thanks for your help.
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