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 CCS Technical Support

Echo in Rs485

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



Joined: 22 Aug 2005
Posts: 275

View user's profile Send private message

Echo in Rs485
PostPosted: Fri Oct 10, 2014 8:46 am     Reply with quote

Hi to All,

I want to drive RS485 modem with AT command. When I send command in received buffer I have also echo of tx instead only answer from modem.

This is example:

Code:

/****************************************************************************
*                                 main.c                                    *
*---------------------------------------------------------------------------*

*/
#define debug

#include "18F46K22.h"
#include "DEF452.C"

//_______________________________________________________________________Setup
#if defined(debug)
   #fuses HSM,NOPBADEN,DEBUG,NOWDT,NOPROTECT,NOPUT,NOBROWNOUT,CPD,NOLVP,NODEBUG,NOCPB,STVREN,NOPLLEN,NOFCMEN
   #device ADC=10 icd=true

   #else
   #fuses HSM,NOPBADEN,NODEBUG,WDT,PROTECT,PUT,CPD,NOLVP,BORV29,CPB,STVREN,NOPLLEN,NOFCMEN
   #device  ADC=10
   #endif

#device *=16 ADC=10

//______________________________________________________________Abilita Delay
#use delay(clock=16000000,RESTART_WDT)                               

#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7,enable=PIN_C5,restart_wdt,errors,stream=MODEM)



char buffer_rx[200];
int counter_rx;


#USE FAST_IO(A)
#USE FAST_IO(B)
#USE FAST_IO(C)



#define true 1
#define false 0

#INT_RDA
void SerialInt()
{
   buffer_rx[counter_rx]=fgetc(MODEM);       // Gets chars from uart
   counter_rx++;                                 // Increment counter
      if(counter_rx>=200)
         counter_rx=0;                     // Circle Buffer
}



void main() {
set_tris_a(0b00000001);
set_tris_b(0b01000000);
set_tris_c(0b10000000);
set_tris_d(0xFF);
set_tris_e(0x00);


PORTA=0;
PORTB=0b11000000;
PORTC=0;
PORTD=0;
PORTE=0;

setup_timer_0(RTCC_DIV_64|RTCC_INTERNAL|RTCC_8_BIT);   
enable_interrupts(INT_RDA);
enable_interrupts(GLOBAL); 
    /* Setup iniziale inverter */                 

    while(true){
   restart_wdt();
   buffer_rx="";
   counter_rx=0;
   printf("AT\r");                     // Send Attention Command
    delay_ms(2000);
   delay_cycles(1);
   }
}

I tried to change manually enable of RS485 driver without solve problem.

Can somebody help me to solve this problem ?
ezflyr



Joined: 25 Oct 2010
Posts: 1019
Location: Tewksbury, MA

View user's profile Send private message

PostPosted: Fri Oct 10, 2014 10:51 am     Reply with quote

Hi,

Are you sure it's not the modem echoing the Rx data? Most AT command 'modems' will do this by default, but this feature can be disabled. Here is how I disable command echoing on an ADH8066 GSM modem based project:

Code:

   // Here we turn OFF AT command echoing from the ADH8066 module!
   fprintf(ADH8066, "ATE0\r");
   delay_ms(500);


John
Fabri



Joined: 22 Aug 2005
Posts: 275

View user's profile Send private message

PostPosted: Fri Oct 10, 2014 11:10 am     Reply with quote

Thanks John,

After now "ATE0\r" I don't receive "AT" echo.

I didn't think about it because with PC and terminal I haven't echo. I can't realize it why.

Anyway I solved it !

Regards,
Fabri
temtronic



Joined: 01 Jul 2010
Posts: 9237
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Fri Oct 10, 2014 12:44 pm     Reply with quote

Ok maybe I'm blind from welding today but just where do you actually print out the received data from the modem ??
Fabri



Joined: 22 Aug 2005
Posts: 275

View user's profile Send private message

PostPosted: Fri Oct 10, 2014 1:04 pm     Reply with quote

Dear temtronic,

This is only for test and I use ICD3 in debug mode. I don't printout received data. I only watch received buffer in MPLAB.
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