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

Picdem to Picdem receiving problem

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



Joined: 22 Sep 2016
Posts: 4

View user's profile Send private message

Picdem to Picdem receiving problem
PostPosted: Thu Sep 22, 2016 3:52 am     Reply with quote

Hello I'm new in programming and I'm trying to make a simple transmit-receive program between two picdemos using the TXD and RXD. I checked with oscilloscope the transmit wire and it seems to send the data but in the receiver the LED doesn't blink.
The code for transmitter:
Code:

#include <16F877A.h>
#use delay(CLOCK=4000000)
#use rs232(baud=9600,PARITY=N,XMIT=PIN_C6,RCV=PIN_C7)
#define LED_PIN PIN_B1
 
void main()
{
output_low(PIN_B1);
   while(TRUE)
   {
   printf("hello");
   delay_ms(1500);
   output_toggle(PIN_B1);
   delay_ms(100);
   output_toggle(PIN_B1);
   
   }
   
   }

The code for receiver:

Code:

#include <18F452.h>
#use delay(clock=9000000)
#use rs232(baud=9600,XMIT=PIN_C6,RCV=PIN_C7)

#define LCD_ENABLE_PIN PIN_D6
#define LCD_RS_PIN PIN_D4
#define LCD_RW_PIN PIN_D5
#define LCD_DATA4 PIN_D0
#define LCD_DATA5 PIN_D1
#define LCD_DATA6 PIN_D2
#define LCD_DATA7 PIN_D3
#include <lcd.c>

char read;

void main()
{
output_low(PIN_B1);
output_high(pin_d7);
lcd_init();
lcd_putc("\fHello\n");

 while(TRUE)
 {
  if (khbit)
  {
   output_toggle(PIN_B1);
   delay_ms(1000);
   output_toggle(PIN_B1);
   //getc(read);
   //printf(lcd_putc, "Message:%c", read ); 
   //lcd_putc(read);
  }
 }
}
temtronic



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

View user's profile Send private message

PostPosted: Thu Sep 22, 2016 5:26 am     Reply with quote

1st Q.
Do you really have a nine MHX xtal in the rcv PIC PCB ?

1st C.
Everytime you use the hardare UART,you need to add 'errors' to the USE RS232(...options...). This will clear the UART from an OE condition( 3 chars or more, rcvd but not serviced.

Jay
arisk4



Joined: 22 Sep 2016
Posts: 4

View user's profile Send private message

PostPosted: Thu Sep 22, 2016 6:03 am     Reply with quote

1st. Yes i have a PICTail in the pcb with the all the pins. The pic is mounted on Picdem 2 plus board.
2nd. I added the error option but nothing changed.
Ttelmah



Joined: 11 Mar 2010
Posts: 19447

View user's profile Send private message

PostPosted: Thu Sep 22, 2016 7:05 am     Reply with quote

Quote:

1st Q.
Do you really have a nine MHX xtal in the rcv PIC PCB ?


I'll repeat Temtronic's question.

The PICDem2 plus board has a 4MHz oscillator. Do you have a 9MHz one!. This is what you are telling the receiver code.....
arisk4



Joined: 22 Sep 2016
Posts: 4

View user's profile Send private message

PostPosted: Thu Sep 22, 2016 7:14 am     Reply with quote

yes the receiving board has an 9MHz. The two board must be in the same frequency?
Ttelmah



Joined: 11 Mar 2010
Posts: 19447

View user's profile Send private message

PostPosted: Thu Sep 22, 2016 7:37 am     Reply with quote

No, but 9MHz, is a very 'odd' frequency. Normally only used for crystal filter units.

Before doing anything else, prove that this is really what you have:
Code:

//for the receiver
#include <18F452.h>
#fuses NOWDT, HS
#use delay(clock=9000000)

void main(void)
{
   output_low(PIN_B1);
   while(TRUE)
   {
       delay_ms(1000);
       output_toggle(PIN_B1);
   }
}


Time the pulses on B1. Are they at 0.5Hz?. If not, your crystal is not 9Mhz (or is not actually a normal crystal - the filter units look like crystals, in some cases, but won't resonate properly).
arisk4



Joined: 22 Sep 2016
Posts: 4

View user's profile Send private message

PostPosted: Thu Sep 22, 2016 9:56 am     Reply with quote

After all the oscillator wasn't 9MHz(they told me it was Very Happy ) and i couldn't find the right frequency. I put another 4MHz oscillator and im receiving something now. Thanks for the help and quick answers!!!!
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