Searching \ for '[PIC] sn75176 problem' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/devices.htm?key=pic
Search entire site for: 'sn75176 problem'.

Exact match. Not showing close matches.
PICList Thread
'[PIC] sn75176 problem'
2009\06\23@154441 by chaconne

picon face

hi!
i am making a serial connection rs485 between pic18f452 and pic16f628.
The procedure is one send byte message the other get it and replies as an ok
msg. This happens three times. Then the receiver becomes the sender and the
same procedure occurs.
Now, the program works if i connect RX and TX pins directly. But when i use
sn75176, one for each pic, it doesn't work. I set the DeRe pin high before
the message sending and clear it after sending, this is the nearly only
difference at the code. No data transmission. If i put a big delay(150ms)
after sending msg, two or three transmissions seems to happen. Then it is
locked again. What can the problem be? Do you have a guess. I will send the
codes when i prepare them for sending.

Thanks!

Note: I use no interrupts.
Note2: I have put pullup res to the rx pins.
--
View this message in context: www.nabble.com/sn75176-problem-tp24172473p24172473.html
Sent from the PIC - [PIC] mailing list archive at Nabble.com.

2009\06\23@163645 by Isaac Marino Bavaresco

flavicon
face
chaconne escreveu:
> hi!
> i am making a serial connection rs485 between pic18f452 and pic16f628.
> The procedure is one send byte message the other get it and replies as an ok
> msg. This happens three times. Then the receiver becomes the sender and the
> same procedure occurs.
> Now, the program works if i connect RX and TX pins directly. But when i use
> sn75176, one for each pic, it doesn't work. I set the DeRe pin high before
> the message sending and clear it after sending, this is the nearly only
> difference at the code. No data transmission. If i put a big delay(150ms)
> after sending msg, two or three transmissions seems to happen. Then it is
> locked again. What can the problem be? Do you have a guess. I will send the
> codes when i prepare them for sending.
>
> Thanks!
>
> Note: I use no interrupts.
> Note2: I have put pullup res to the rx pins.
>  

Are you waiting for the last byte transmission to complete before
disabling the transmitter? If you disable the transmitter right after
writing the last byte to TXREG, then it will not be transmitted (at
least not complete).

You should wait some time also before the other device enable its
transmitter.

Regards,

Isaac

__________________________________________________
Faça ligações para outros computadores com o novo Yahoo! Messenger
http://br.beta.messenger.yahoo.com/

2009\06\23@170439 by chaconne

picon face

Codes are like below. I have put a 150ms delay after TXREG = byte, one or two
more transmission are done. The process as i observe is, picA sends one
byte, picB gets it, picB send OK msg but picA doesnt get it, also picB gets
one more message although there are no sent msg from picA.

Note: I only send one byte in one transmission.

Thanks.

Code:

// serLib.h
#ifndef SERLIB_H_
#define SERLIB_H_

#endif /*SERLIB_H_*/

#define BAUD 9600      
#define FOSC 4000000L
#define NINE 0     /* Use 9bit communication? FALSE=8bit */

#define DIVIDER ((int)(FOSC/(16UL * BAUD) -1))
#define HIGH_SPEED 1

#if NINE == 1
#define NINE_BITS 0x40
#else
#define NINE_BITS 0
#endif

#if HIGH_SPEED == 1
#define SPEED 0x4
#else
#define SPEED 0
#endif

#define   RX_PIN TRISB1
#define   TX_PIN TRISB2

//void SendChar(unsigned char);
unsigned char ReceiveChar(void);
unsigned char getche(void);
void init_comms(void);

void init_comms()
{
  TRISB1 = 1;
  TRISB2 = 0;
  SPBRG = DIVIDER;
  RCSTA = (NINE_BITS|0x90);
  TXSTA = (SPEED|NINE_BITS|0x20);
  //RCIE = 1;
  //GIE = 1;
}

void SendChar(unsigned char byte)
{
  serialEnable = SEND_ENABLE;
  while(!TXIF)
     continue;
  TXREG = byte;
  serialEnable = RECEIVE_ENABLE;
}

unsigned char ReceiveChar()
{
  return RCREG;
}

Code:

// SerialProcesses.h
void SerialProcesses()
{
  char temp;
  if(serialMode == WAIT_MODE)
  {
     if(RCIF)
     {
        if(serialIndexTX == 3)
        {
           arrayDataOut[serialIndexRC] = ReceiveChar();
           serialIndexRC++;
           if(serialIndexRC > 2)
           {
              serialIndexTX = 0;
              serialMode = SEND_MODE;
           }
           else
           {
              serialMode = SEND_MODE;
              b_sendOk = 1;
           }
        }
        else
        {
           if(ReceiveChar() == 55)
           {
              serialMode = SEND_MODE;
           }
        }
        RCIF = 0;
     }
  }
  else
  {
     if(b_sendOk == 1)
     {
        SendChar(55);
        serialMode = WAIT_MODE;
        b_sendOk = 0;
     }
     else
     {
        SendChar(arrayDataIn[serialIndexTX]);
        if(++serialIndexTX > 2)
        {
           serialIndexRC = 0;
           serialMode = WAIT_MODE;
        }
        else
        {
           serialMode = WAIT_MODE;
        }
     }
  }
  return;
}

Code:

// StartUp.h
void StartUp()
{
  TRISA = 0;
  TRISB = 0b10000010;
  PORTA = 0;
  PORTB = 0;
  GIE = 0;
   
  init_comms();
   
  return;
}

Code:

// picA Main
void main(void)
{
  StartUp();

       serialMode = SEND_MODE;
  serialIndexRC = 3;
  serialEnable = SEND_ENABLE;
  serialEnableReg = 1;
   
  while(1)
  {
     DataIn();
     SerialProcesses();
     DataOut();
  }
   
  return;
}

Code:

// picB Main
void main(void)
{
  StartUp();

       serialMode = WAIT_MODE;
  serialIndexRC = 3;
  serialEnable = RECEIVE_ENABLE;
  serialEnableReg = 1;
   
  while(1)
  {
     DataIn();
     SerialProcesses();
     DataOut();
  }
   
  return;
}
--
View this message in context: www.nabble.com/sn75176-problem-tp24172473p24174430.html
Sent from the PIC - [PIC] mailing list archive at Nabble.com.

2009\06\24@045012 by Dario Greggio

face picon face
chaconne ha scritto:
> Codes are like below. I have put a 150ms delay after TXREG = byte, one or two



I'd say you have to check for RX errors - overrun, framing - or the
receiver will stop working.

2009\06\24@051229 by Yusuf Özkay

picon face
You are right, the problem is about frame error. But what is the reason of
it, i couldn't find it yet.

2009/6/24 Dario Greggio <spam_OUTadpm.toTakeThisOuTspaminwind.it>

> chaconne ha scritto:
> > Codes are like below. I have put a 150ms delay after TXREG = byte, one or
> two
>
>
>
> I'd say you have to check for RX errors - overrun, framing - or the
> receiver will stop working.
> -

2009\06\24@052431 by Dario Greggio

face picon face
Yusuf Özkay ha scritto:
> You are right, the problem is about frame error. But what is the reason of
> it, i couldn't find it yet.
>


Well, it can be anything, from glitches at power suppplly, to glithes in
the state of 485 A-B lines when switching from TX to RX - btw, do you
have pull-up and pull-down at A and B?

2009\06\24@055247 by Yusuf Özkay
picon face
I am doing simulation at proteus and i didn't connect pullups to the A and B
lines.I have connected pullup only to the RX pins. Is þt necessary at
simulation?

2009/6/24 Dario Greggio <.....adpm.toKILLspamspam@spam@inwind.it>

> Yusuf Özkay ha scritto:
> > You are right, the problem is about frame error. But what is the reason
> of
> > it, i couldn't find it yet.
> >
>
>
> Well, it can be anything, from glitches at power suppplly, to glithes in
> the state of 485 A-B lines when switching from TX to RX - btw, do you
> have pull-up and pull-down at A and B?
>

2009\06\24@060910 by Dario Greggio

face picon face
Yusuf Özkay ha scritto:
> I am doing simulation at proteus and i didn't connect pullups to the A and B
> lines.I have connected pullup only to the RX pins. Is þt necessary at
> simulation?


Oh well, i don't know: but, without them, A and B will float and the
receiver will get "spurious bytes" thus causing the RX errors...

2009\06\24@062039 by Yusuf Özkay

picon face
I put pullup and pulldown with 4k7 and I put 1k between A and B lines. It
didn't work. I will try it in real simulation now. Hope it works.
Thanks.

24 Haziran 2009 13:09 tarihinde Dario Greggio <adpm.tospamKILLspaminwind.it> yazdý:

> Yusuf Özkay ha scritto:
> > I am doing simulation at proteus and i didn't connect pullups to the A
> and B
> > lines.I have connected pullup only to the RX pins. Is þt necessary at
> > simulation?
>
>
> Oh well, i don't know: but, without them, A and B will float and the
> receiver will get "spurious bytes" thus causing the RX errors...
>

2009\06\24@072636 by Yusuf Özkay

picon face
I tried at real simulation same thing happens.One byte is sent from A, that
is received by B. B sends one byte, and that is received by A. A sends one
byte but this byte is not received by B. No more communication happens.

24 Haziran 2009 13:20 tarihinde Yusuf Özkay <.....yusufozkayKILLspamspam.....gmail.com> yazdý:

{Quote hidden}

>> -

2009\06\24@160229 by Richard Prosser

picon face
Yusuf,

2009/6/24 Yusuf Özkay <yusufozkayspamspam_OUTgmail.com>:
> I tried at real simulation same thing happens.One byte is sent from A, that
> is received by B. B sends one byte, and that is received by A. A sends one
> byte but this byte is not received by B. No more communication happens.
>

Are you sure that the RX/TX switch is operating correctly? If the
timing is too long between the end of the transmit packet and the
transmitter switching off then you _could_ get the the effect above,
It will depend on the amount of processing / packet verification going
on as well. For example, in the above: if the second response from 'A'
is just an acknowlegement, it could be sending it before B is ready to
receive. It didn't happen the first time because 'A' had to process
the data, calculate CRCs etc.

Even if you have the RX permanently enabled, it's the TX switching on
and off that is going to create the issue.

RP

More... (looser matching)
- Last day of these posts
- In 2009 , 2010 only
- Today
- New search...