View previous topic :: View next topic |
Author |
Message |
pulsar.nova12
Joined: 06 Jul 2017 Posts: 5 Location: colombia
|
Communication rs232 problem in transmission |
Posted: Thu Jul 06, 2017 10:18 am |
|
|
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: 9246 Location: Greensville,Ontario
|
|
Posted: Thu Jul 06, 2017 10:21 am |
|
|
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
|
|
Posted: Sat Jul 08, 2017 8:59 am |
|
|
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: 1358
|
|
Posted: Sat Jul 08, 2017 10:23 am |
|
|
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
|
not solution |
Posted: Fri Aug 04, 2017 2:17 pm |
|
|
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: 9246 Location: Greensville,Ontario
|
|
Posted: Fri Aug 04, 2017 2:31 pm |
|
|
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 |
|
|
|