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

Communication rs232 problem in transmission

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



Joined: 06 Jul 2017
Posts: 5
Location: colombia

View user's profile Send private message

Communication rs232 problem in transmission
PostPosted: Thu Jul 06, 2017 10:18 am     Reply with quote

Good morning, I'm doing a circuit with 16f877a. I make the connection via rs232 to the pc with a usb to serial adapter. In this moment I get characters from the pc and display them on an lcd screen, but when trying to send data from the microcontroller to the pc, the information is sent to the lcd and not to the port.
I try loading a character directly to the records instead of sending data but just send it to the lcd. Who can help me?
Thank you
temtronic



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

View user's profile Send private message

PostPosted: Thu Jul 06, 2017 10:21 am     Reply with quote

You need to post a small program that shows us what's happening...
It 'sounds' like your print function is going to the LCD module NOT the UART port of the PIC though.
pulsar.nova12



Joined: 06 Jul 2017
Posts: 5
Location: colombia

View user's profile Send private message

PostPosted: Sat Jul 08, 2017 8:59 am     Reply with quote

This is my code:
Code:

//*miproyecto.h
#include <16F877A.h>
#device ADC=10
#FUSES XT
#FUSES NOBROWNOUT               //No brownout reset
#FUSES NOLVP                    //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOWDT
#use delay(crystal=4MHz)
#use rs232(baud=9600,xmit=pin_c6,rcv=pin_c7)

----------------------------------------------
// *miproyecto.c
#include <miproyecto.h>

#define LCD_ENABLE_PIN PIN_B0
#define LCD_RS_PIN PIN_B1
#define LCD_RW_PIN PIN_B2
#define LCD_DATA4 PIN_B3
#define LCD_DATA5 PIN_B4
#define LCD_DATA6 PIN_B5
#define LCD_DATA7 PIN_B6

#BYTE  TXREG = 0x19
#BYTE  TXEN = 0x98

char cadena[16];
int index=0;

#INT_RDA
void RDA_isr(){
if(kbhit()){
char dato=getc();
if(dato=='.'){
    index=0;
    dato="";
}else{
   if(index==0){
   cadena="            ";
   }
   cadena[index]=dato;
   index++;
    }
  }
clear_interrupt(INT_RDA);
}

void envio_dato(char dato){
TXREG=dato;
 bit_set(TXEN,5);
}

#include <lcd.c>
void main(){
   enable_interrupts(INT_RDA);
   enable_interrupts(GLOBAL);
   lcd_init();
   lcd_putc("\f PRUEVA COM \n");
   delay_ms(500);
   while(TRUE)
   {
     lcd_gotoxy(1,2);
     printf(lcd_putc,"%s \n",cadena);
     envio_dato('0');
     delay_ms(500);
   }

When I do the simulation in proteus works well, but when implementing it physically presents the problem.

Thanks for your help.

++++++++++++++++++++
Maquina1991 who was assisting you is banned as a software pirate.

See forum rule #9:
9. No pirating

Forum rules:
http://www.ccsinfo.com/forum/viewtopic.php?t=26245

- Forum Moderater
++++++++++++++++++++
jeremiah



Joined: 20 Jul 2010
Posts: 1349

View user's profile Send private message

PostPosted: Sat Jul 08, 2017 10:23 am     Reply with quote

That's because Proteus is mostly flawed when it comes to simulating PIC micros. In particular:

Code:

if(index==0){
   cadena="            ";
   }


Is not valid C. It doesn't do what you think it does. See the memset() function.
pulsar.nova12



Joined: 06 Jul 2017
Posts: 5
Location: colombia

View user's profile Send private message

not solution
PostPosted: Fri Aug 04, 2017 2:17 pm     Reply with quote

Good afternoon, I still can not send data from the micro to the pc, I still send the data by a physical port of the pic and not by the data sending pin
temtronic



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

View user's profile Send private message

PostPosted: Fri Aug 04, 2017 2:31 pm     Reply with quote

Simple solution... press F11 while your project is open..this opens the CCS C Manual. Find 'putc' in the menu.... read the description....
Also, check the FAQ section of the manual, as they show how to send data to PC
Finally, check several of the examples in the 'examples' folder . Most have sending data to PC. Some use putc() some use printf()..

Jay
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