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

get DATA from RS232 and affect it to 7SEG BCD

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



Joined: 12 Apr 2011
Posts: 7

View user's profile Send private message

get DATA from RS232 and affect it to 7SEG BCD
PostPosted: Thu Apr 14, 2011 2:38 pm     Reply with quote

This is a simple program but it doesn't work for me, can someone tell me where's the problem.
Code:

#include <16F877.h>
#device *=16
//#fuses HS, NOWDT, NOLVP, NOBROWNOUT, NOPROTECT, PUT
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7,enable=PIN_B4, stream=PC)


int8 msg[40];
int8 next_in=0;
void main() {
 
  set_tris_a(0x00);
  while(true) {
  if(kbhit(PC)){

  output_high(PIN_A0);
  delay_ms(200);
  output_a(fgetc());
}
delay_ms(200);

}

}
temtronic



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

View user's profile Send private message

PostPosted: Thu Apr 14, 2011 3:02 pm     Reply with quote

some errors , NOT all..
1) #fuses setup has been commented out...

2) #rs232() must have 'errors' option, and 'enable.." NOT required

3) set_tris_a(..) NOT required, but left for experienced programmers

4) msg_in not use, not an error, but not required

5) same for next _in


hardware...do you have a MAX232 or equal in circuit?
proper xtal/caps ?

that's a few of your problems...
helmi03



Joined: 12 Apr 2011
Posts: 7

View user's profile Send private message

PostPosted: Thu Apr 14, 2011 3:17 pm     Reply with quote

Thank you for answering me yes all the problem you told i know about it, MY problem i just want to get a int and put it to 7SEG BCD , my circuit is :

i use COMPIM => MAX232==>MAX487==>MAX487==>PIC==>7Seg

I use the MAX487 because i will after add 2 other pic and use RS485, I want to create my own protocol so i will not use RS485.c , in this code I'm just get data int8 i = getc(); and want to put it in the BCD 7seg by output_a(i);

Thank you for helping me
temtronic



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

View user's profile Send private message

PostPosted: Thu Apr 14, 2011 6:01 pm     Reply with quote

Start small, get your program to work with only 1 PIC connected via RS232.
Get ALL the bugs out THEN add the RS485 code and chips.
Adding RS485 should only take 1/2 hour max ONCE your 'core' program is bug free.

By doing it in these steps you will save hours if not days of time.
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