View previous topic :: View next topic |
Author |
Message |
helmi03
Joined: 12 Apr 2011 Posts: 7
|
get DATA from RS232 and affect it to 7SEG BCD |
Posted: Thu Apr 14, 2011 2:38 pm |
|
|
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);
}
} |
|
|
![](templates/subSilver/images/spacer.gif) |
temtronic
Joined: 01 Jul 2010 Posts: 9174 Location: Greensville,Ontario
|
|
Posted: Thu Apr 14, 2011 3:02 pm |
|
|
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... |
|
![](templates/subSilver/images/spacer.gif) |
helmi03
Joined: 12 Apr 2011 Posts: 7
|
|
Posted: Thu Apr 14, 2011 3:17 pm |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
temtronic
Joined: 01 Jul 2010 Posts: 9174 Location: Greensville,Ontario
|
|
Posted: Thu Apr 14, 2011 6:01 pm |
|
|
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. |
|
![](templates/subSilver/images/spacer.gif) |
|