Author Topic: SBC68EC USART Comm. Issue  (Read 2522 times)

jjjjjjjjjjjjjjjjjjjjjjjjj

  • Newbie
  • *
  • Posts: 4
    • View Profile
SBC68EC USART Comm. Issue
« on: August 09, 2013, 08:45:26 AM »
Hello,
I'm attempting to use an SBC68EC to communicate over serial with a device on rs485.  I'm using DS75176BTN to convert the rs485 to USART at TTL levels and I've verified this is working properly on a scope and in a terminal.  Additionally I shorted pins J1 and J2 and shorted J3 and J4 to configure the board to operate the com port on TTL levels.

The issue I'm having is that the board will not register that anything is being transmitted through the read bus (SIG0) on the board.  The hw interrupt is definitely being triggered but when I attempt to read using serGetByte(); it does not return anything at all (or so it seems), the variable I'm assigning it to remains the same value it is initialized to, not the incoming byte's value.
I guess it's also worth noting I've tried Microchip's USART library too, however I had the same issue and I couldn't call the OpenUSART() command, so it was pretty useless.

Any response would be greatly appreciated,
Thanks in advance!

modtro2

  • Administrator
  • Hero Member
  • *****
  • Posts: 564
    • View Profile
Re: SBC68EC USART Comm. Issue
« Reply #1 on: August 19, 2013, 01:43:02 PM »
Hi, I attached the code for a project we did a while ago. It uses a PIC18 to send and receive messages via RS-485.

You can have a look at the code, specially the sendMessage() function. It send a whole message with multiple bytes 3 times. The part of the code that sends a single byte is:

Code: [Select]
           TX_ENABLE = 1;  //Enable RS-485 driver

            //Write next byte to USART
            TXREG1 = msg[i];      // Write the data byte to the USART2

            while (TXSTA1bits.TRMT == 0) {
                //Wait, do nothing
            }

            //delay100uS(1);    //Delay 100us
            TX_ENABLE = 0;      //Disable RS-485 driver
            delayMS(1);         //Put 1ms delay between bytes

Maybe this helps? This important thing to note is the "TX_ENABLE" pin of your RS-485 driver is ONLY enabled during transmission! When done transmitting, it must immediately be disabled! Else, you will not be able to receive anything!