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

Please Get RS485.C.

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



Joined: 30 Mar 2009
Posts: 5
Location: São Paulo, Brasil

View user's profile Send private message

Please Get RS485.C.
PostPosted: Sun Jul 26, 2009 4:14 pm     Reply with quote

Good night,

I'm using Google translator.

I need a help from you, before posting to search the entire forum to try to solve my problem, I looked 8 pages relating to driver communication (rs485.c). But it seems that nobody has "receive data with it."

Before starting to develop my software I'm testing the driver RS485.c of CCS, and appeared a problem that I am not getting resolved.

I wrote this firmware just to get a bus for any 485 and confirm the receipt by bus rs232. But this does not happen!

Question:

Structure to receive data using the "Driver rs485.c" are correct? Or my firmware is wrong?


My function: rs485_get_message(ponteiro,true) returns 0 "False"!!!!

Thank you all!

From Brasil - São Paulo-SP.

------------------------------------------------------------------------------------
Bom noite ,

Estou usando o tradutor Google.

Preciso de uma ajuda de vocês, antes de postar pesquisei o fórum inteiro para tentar solucionar o meu problema, olhei 8 paginas referente ao driver de comunicação (rs485.c). Mas parece que ninguém conseguiu “receber dados com ele”.

Antes de começar a desenvolver o meu software estou testando o driver RS485.c da CCS, e apareceu um problema que não estou conseguindo resolver.

Escrevi este firmware apenas para receber um dado qualquer pela bus 485 e confirmar o recebimento pela bus rs232. Mas isso não ocorre !

Pergunta:

Estrutura para receber os dados utilizando o “Driver rs485.c” estão corretos? Ou meu firmware es está errado?

Minha função: rs485_get_message(ponteiro,true) Retorna 0 "False"

Obrigado a todos !

De Brasil - São Paulo - SP.

---------------------------------------------------------------------------------

Code:
// Test RS485 Communications:
// Receive Message.

#include <16F628A.h>

#fuses HS, NOWDT, NOLVP, NOBROWNOUT, NOPROTECT, PUT
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_B2, rcv=PIN_B1, stream=PC)

#define  RS485_USE_EXT_INT    TRUE

#define RS485_RX_PIN       PIN_B0 
#define RS485_TX_PIN       PIN_B3


int8 MOD_RS485_ID = 0x07; // Endereço do Modulo. my adress

#define RS485_ID MOD_RS485_ID //Atribuir o Endereço.

#include <rs485.c>  // Driver para Comunicação

int8 bufferget[];   //Dados recebidos.
int8 *ponteiro;     //teste para ponteiro de recepção.


void main()
{
     
   rs485_init();

   fprintf(pc,"Module SLAVE to Receive Message."); //RS232 PC (RB1 RX /RB2 TX)   
   
   ponteiro = bufferget;
   
   while(true)
   {
           
     if(rs485_get_message(ponteiro,true)) //RS485 (RB0 RX /RB3 TX /RB4 DE /RB5 RE)
       {   
        fprintf(pc,"\n\rMessage received."); //RS232 PC (RB1 RX /RB2 TX)
       }
   }
}
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Mon Jul 27, 2009 6:56 pm     Reply with quote

I never use the rs485.c but here are a few hints:
Code:
int8 bufferget[];   //Dados recebidos.
This only declares a pointer, not a buffer. Change to:
Code:
#define MAX_MSG_LENGTH   50
int8 bufferget[MAX_MSG_LENGTH];   //Dados recebidos.



Using INT_EXT (pin_B0) limits the baudrate to a maximum of 19.200 baud for a 20MHz clock.

How are you sending the data from the PC?
monttec



Joined: 30 Mar 2009
Posts: 5
Location: São Paulo, Brasil

View user's profile Send private message

PostPosted: Mon Jul 27, 2009 7:27 pm     Reply with quote

Thank you for answering my question.

To solve the problem!

Thanks ckielstra same!
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