Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Problem with the DS1621 and 16F819 and the RS-232 communicat

Status
Not open for further replies.

otavio_fisica

Newbie level 1
Joined
Dec 6, 2006
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,303
ds1621

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.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top