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

Re: Problems using 2 x serial ports

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







Problems using 2 x serial ports
PostPosted: Wed Dec 11, 2002 4:47 am     Reply with quote

Hello all,

Im working with a PIC16F870 & PCM version 3.007.

My project needs 1 x RS232 port and 1 x RS485 port. For RS232 I am using a software port. For RS485 I am using the hardware port.

The main part of the program continually goes round in a loop switching various LED's and RELAYS etc., within that loop the serial ports toggle between RS232/RS485 approx. every half second. So for one cycle it switches to RS232, the next RS485 and back to RS232 and so on.
When RS232, I go to a function called Timed_getc() where I use the kbhit to time out if a certain amount of characters are not received. This works fine if I disable the switching to the RS485. If I enable RS485, the RS232 doesn't work (the main loop continues fine but the PIC doesn't appear to receive the characters, thus it times out and goes back to main loop).
Here's how I switch between the comms...

if(comms==comm_rs232) {
#use rs232(baud=4800,parity=N,xmit=PIN_UTX,rcv=PIN_URX) // Select RS232 serial comms
}
else {
#use rs232 baud=4800,parity=N,enable=PIN_RS485FLO,xmit=PIN_DI,rcv=PIN_RO) // Select RS485 serial comms
}

As can be seen, I use the boolean variable "comms" to determine which port to use. This variable is toggled as said above, about once every 0.5 seconds.

The RS232 port does use an RS232 device (max232). At this time, I do not have an RS485 chip fitted. Strangely, the PIC hung at power on if I didn't tie the RS485 Rx to +5V.

Here's the program (in brief):

#int_timer2
timer2_isr() { // this counts in seconds

if(ticktime--==0) {
ticktime=17;
secs++;
// some other code in here, not worth printing
}
}

#int_rda
rda_isr() { // RS485 serial char in service routine

string[RS485StrPointer]=getc();
if(string[RS485StrPointer]==':') {
RS485StrPointer=1;
}
else {
RS485StrPointer++;
if(RS485StrPointer==21) {
RS485StrPointer=0;
process_serial();
}
}
}

void main() {
int i;
char serin;
long adval;

initsys();

while(1) {
if(comms==comm_rs232) {
#use rs232(baud=4800,parity=N,xmit=PIN_UTX,rcv=PIN_URX)// Select RS232 serial comms
}
else {
#use rs232 baud=4800,parity=N,enable=PIN_RS485FLO,xmit=PIN_DI,rcv=PIN_RO)// Select RS485 serial comms
}

if(comms==comm_rs232) {
serin=timed_getc(); // timed_getc() times out after about 500mS
}
else {
delay_ms(400); // RS485 comms doesn't time out as it is hardware interrupt driven
}
// other code in here not worth printing
}

char timed_getc() {

long timeout;
int strpointer;

timeout=0;

while(!kbhit() && (++timeout<20000)) { // 200mS
delay_us(5);
}

if(kbhit()) {
string[0]=getc();
if(string[0]!=':') {
return(0);
}
else {
for(strpointer=1;strpointer<21;strpointer++) {
timeout=0;
while(!kbhit() && (++timeout<200)) {
delay_us(5);
}
if(kbhit()) {
string[strpointer]=getc();
}
else {
return(0); // timed out so return
}
}
// got all 21 characters
process_serial();
return('V'); // V for Valid string !
}
}
else {
return(0); // timed out so return
}
}

void process_serial(void) {

byte i,startaddr,numbytes;
byte checksum=0;
byte sysvals[6];

for(i=1;i<19;i++) {
checksum=(checksum ^ string[i]); // Exlusive OR 18 bytes to find checksum. 19th byte = checksum
}
/* String format / command definitions:

STRING: :aCsbbbbbbbbbbbbbbbm
: = start of string
a = address (0-31. All respond to 0)
C = command
s = start eeprom address (MS nibble), number of bytes to read/write (LS nibble)
b = bytes (tot. 15)
m = checksum (Xor of a,C,s and bytes)
<cr> = carriage return (end of string)

Command set:

W = write bytes
R = read bytes
r = read ALL live system values
*/

MyAddress=read_eeprom(16);

if(((checksum==string[19]) && (string[20]==13)) && ((MyAddress==String[1]) || (String[1]==0))) {
// Checksums match, string ends in <cr> and address either matches or is 0

startaddr=(string[3] & 0xF0)/16; // Shift right by 4
numbytes=(string[3] & 0x0F); // LS nibble

switch (string[2]) {
// do some case statements in here...
}
}


The rest of my code works ok, it's the switching between the two comms that the PIC doesn't seem to like.

Regards,
Darren
___________________________
This message was ported from CCS's old forum
Original Post ID: 9966
nilsener
Guest







Re: Problems using 2 x serial ports
PostPosted: Wed Dec 11, 2002 10:15 am     Reply with quote

Dear,

I have had similar problems switching between two #use rs232 statements, it was on a PIC18F452.

I solved the problem using the STREAM directive.

Example: (locate the two '#use rs232' to your preprocessor statements)

#use rs232 (BAUD=2400,XMIT=PIN_C6,RCV=PIN_C7,RESTART_WDT,ERRORS,STREAM = DISPLAY)
#use rs232 (BAUD=2400,XMIT=PIN_B1,RCV=PIN_B0,RESTART_WDT,ERRORS,STREAM = SCANNER)


Then you must use fgetc(DISPLAY) // receives via PIN C7
instead of getc()

and fgetc(SCANNER) // receives via PIN B0

have a look to fputc(SCANNER) instead of putc()
and kbhit(SCANNER) instead of kbhit(), too.

regards nilsener


:=Hello all,
:=
:=Im working with a PIC16F870 & PCM version 3.007.
:=
:=My project needs 1 x RS232 port and 1 x RS485 port. For RS232 I am using a software port. For RS485 I am using the hardware port.
:=
:=The main part of the program continually goes round in a loop switching various LED's and RELAYS etc., within that loop the serial ports toggle between RS232/RS485 approx. every half second. So for one cycle it switches to RS232, the next RS485 and back to RS232 and so on.
:=When RS232, I go to a function called Timed_getc() where I use the kbhit to time out if a certain amount of characters are not received. This works fine if I disable the switching to the RS485. If I enable RS485, the RS232 doesn't work (the main loop continues fine but the PIC doesn't appear to receive the characters, thus it times out and goes back to main loop).
:=Here's how I switch between the comms...
:=
:=if(comms==comm_rs232) {
:=#use rs232(baud=4800,parity=N,xmit=PIN_UTX,rcv=PIN_URX) // Select RS232 serial comms
:=}
:=else {
:=#use rs232 baud=4800,parity=N,enable=PIN_RS485FLO,xmit=PIN_DI,rcv=PIN_RO) // Select RS485 serial comms
:=}
:=
:=As can be seen, I use the boolean variable "comms" to determine which port to use. This variable is toggled as said above, about once every 0.5 seconds.
:=
:=The RS232 port does use an RS232 device (max232). At this time, I do not have an RS485 chip fitted. Strangely, the PIC hung at power on if I didn't tie the RS485 Rx to +5V.
:=
:=Here's the program (in brief):
:=
:=#int_timer2
:=timer2_isr() { // this counts in seconds
:=
:= if(ticktime--==0) {
:= ticktime=17;
:= secs++;
:=// some other code in here, not worth printing
:= }
:=}
:=
:=#int_rda
:=rda_isr() { // RS485 serial char in service routine
:=
:= string[RS485StrPointer]=getc();
:= if(string[RS485StrPointer]==':') {
:= RS485StrPointer=1;
:= }
:= else {
:= RS485StrPointer++;
:= if(RS485StrPointer==21) {
:= RS485StrPointer=0;
:= process_serial();
:= }
:= }
:=}
:=
:=void main() {
:= int i;
:= char serin;
:= long adval;
:=
:= initsys();
:=
:= while(1) {
:= if(comms==comm_rs232) {
:= #use rs232(baud=4800,parity=N,xmit=PIN_UTX,rcv=PIN_URX)// Select RS232 serial comms
:= }
:= else {
:= #use rs232 baud=4800,parity=N,enable=PIN_RS485FLO,xmit=PIN_DI,rcv=PIN_RO)// Select RS485 serial comms
:= }
:=
:= if(comms==comm_rs232) {
:= serin=timed_getc(); // timed_getc() times out after about 500mS
:= }
:= else {
:= delay_ms(400); // RS485 comms doesn't time out as it is hardware interrupt driven
:= }
:=// other code in here not worth printing
:=}
:=
:=char timed_getc() {
:=
:=long timeout;
:=int strpointer;
:=
:=timeout=0;
:=
:=while(!kbhit() && (++timeout<20000)) { // 200mS
:=delay_us(5);
:=}
:=
:=if(kbhit()) {
:=string[0]=getc();
:=if(string[0]!=':') {
:=return(0);
:=}
:=else {
:=for(strpointer=1;strpointer<21;strpointer++) {
:=timeout=0;
:=while(!kbhit() && (++timeout<200)) {
:=delay_us(5);
:=}
:=if(kbhit()) {
:=string[strpointer]=getc();
:=}
:=else {
:=return(0); // timed out so return
:=}
:=}
:=// got all 21 characters
:=process_serial();
:=return('V'); // V for Valid string !
:=}
:=}
:=else {
:=return(0); // timed out so return
:=}
:=}
:=
:=void process_serial(void) {
:=
:=byte i,startaddr,numbytes;
:=byte checksum=0;
:=byte sysvals[6];
:=
:=for(i=1;i<19;i++) {
:=checksum=(checksum ^ string[i]); // Exlusive OR 18 bytes to find checksum. 19th byte = checksum
:=}
:=/* String format / command definitions:
:=
:=STRING: :aCsbbbbbbbbbbbbbbbm :=
:=: = start of string
:=a = address (0-31. All respond to 0)
:=C = command
:=s = start eeprom address (MS nibble), number of bytes to read/write (LS nibble)
:=b = bytes (tot. 15)
:=m = checksum (Xor of a,C,s and bytes)
:=<cr> = carriage return (end of string)
:=
:=Command set:
:=
:=W = write bytes
:=R = read bytes
:=r = read ALL live system values
:=*/
:=
:=MyAddress=read_eeprom(16);
:=
:=if(((checksum==string[19]) && (string[20]==13)) && ((MyAddress==String[1]) || (String[1]==0))) {
:=// Checksums match, string ends in <cr> and address either matches or is 0
:=
:=startaddr=(string[3] & 0xF0)/16; // Shift right by 4
:=numbytes=(string[3] & 0x0F); // LS nibble
:=
:=switch (string[2]) {
:=// do some case statements in here...
:=}
:=}
:=
:=
:=The rest of my code works ok, it's the switching between the two comms that the PIC doesn't seem to like.
:=
:=Regards,
:=Darren
___________________________
This message was ported from CCS's old forum
Original Post ID: 9977
Mark DSylva
Guest







Re: Problems using 2 x serial ports
PostPosted: Wed Dec 11, 2002 10:34 am     Reply with quote

:=Hello all,
:=
:=Im working with a PIC16F870 & PCM version 3.007.
:=
:=My project needs 1 x RS232 port and 1 x RS485 port. For RS232 I am using a software port. For RS485 I am using the hardware port.
:=
:=The main part of the program continually goes round in a loop switching various LED's and RELAYS etc., within that loop the serial ports toggle between RS232/RS485 approx. every half second. So for one cycle it switches to RS232, the next RS485 and back to RS232 and so on.
:=When RS232, I go to a function called Timed_getc() where I use the kbhit to time out if a certain amount of characters are not received. This works fine if I disable the switching to the RS485. If I enable RS485, the RS232 doesn't work (the main loop continues fine but the PIC doesn't appear to receive the characters, thus it times out and goes back to main loop).
:=Here's how I switch between the comms...
:=
:=if(comms==comm_rs232) {
:=#use rs232(baud=4800,parity=N,xmit=PIN_UTX,rcv=PIN_URX) // Select RS232 serial comms
:=}
:=else {
:=#use rs232 baud=4800,parity=N,enable=PIN_RS485FLO,xmit=PIN_DI,rcv=PIN_RO) // Select RS485 serial comms
:=}
:=
:=As can be seen, I use the boolean variable "comms" to determine which port to use. This variable is toggled as said above, about once every 0.5 seconds.
:=
:=The RS232 port does use an RS232 device (max232). At this time, I do not have an RS485 chip fitted. Strangely, the PIC hung at power on if I didn't tie the RS485 Rx to +5V.
:=
:=Here's the program (in brief):
:=
:=#int_timer2
:=timer2_isr() { // this counts in seconds
:=
:= if(ticktime--==0) {
:= ticktime=17;
:= secs++;
:=// some other code in here, not worth printing
:= }
:=}
:=
:=#int_rda
:=rda_isr() { // RS485 serial char in service routine
:=
:= string[RS485StrPointer]=getc();
:= if(string[RS485StrPointer]==':') {
:= RS485StrPointer=1;
:= }
:= else {
:= RS485StrPointer++;
:= if(RS485StrPointer==21) {
:= RS485StrPointer=0;
:= process_serial();
:= }
:= }
:=}
:=
:=void main() {
:= int i;
:= char serin;
:= long adval;
:=
:= initsys();
:=
:= while(1) {
:= if(comms==comm_rs232) {
:= #use rs232(baud=4800,parity=N,xmit=PIN_UTX,rcv=PIN_URX)// Select RS232 serial comms
:= }
:= else {
:= #use rs232 baud=4800,parity=N,enable=PIN_RS485FLO,xmit=PIN_DI,rcv=PIN_RO)// Select RS485 serial comms
:= }
:=
:= if(comms==comm_rs232) {
:= serin=timed_getc(); // timed_getc() times out after about 500mS
:= }
:= else {
:= delay_ms(400); // RS485 comms doesn't time out as it is hardware interrupt driven
:= }
:=// other code in here not worth printing
:=}
:=
:=char timed_getc() {
:=
:=long timeout;
:=int strpointer;
:=
:=timeout=0;
:=
:=while(!kbhit() && (++timeout<20000)) { // 200mS
:=delay_us(5);
:=}
:=
:=if(kbhit()) {
:=string[0]=getc();
:=if(string[0]!=':') {
:=return(0);
:=}
:=else {
:=for(strpointer=1;strpointer<21;strpointer++) {
:=timeout=0;
:=while(!kbhit() && (++timeout<200)) {
:=delay_us(5);
:=}
:=if(kbhit()) {
:=string[strpointer]=getc();
:=}
:=else {
:=return(0); // timed out so return
:=}
:=}
:=// got all 21 characters
:=process_serial();
:=return('V'); // V for Valid string !
:=}
:=}
:=else {
:=return(0); // timed out so return
:=}
:=}
:=
:=void process_serial(void) {
:=
:=byte i,startaddr,numbytes;
:=byte checksum=0;
:=byte sysvals[6];
:=
:=for(i=1;i<19;i++) {
:=checksum=(checksum ^ string[i]); // Exlusive OR 18 bytes to find checksum. 19th byte = checksum
:=}
:=/* String format / command definitions:
:=
:=STRING: :aCsbbbbbbbbbbbbbbbm :=
:=: = start of string
:=a = address (0-31. All respond to 0)
:=C = command
:=s = start eeprom address (MS nibble), number of bytes to read/write (LS nibble)
:=b = bytes (tot. 15)
:=m = checksum (Xor of a,C,s and bytes)
:=<cr> = carriage return (end of string)
:=
:=Command set:
:=
:=W = write bytes
:=R = read bytes
:=r = read ALL live system values
:=*/
:=
:=MyAddress=read_eeprom(16);
:=
:=if(((checksum==string[19]) && (string[20]==13)) && ((MyAddress==String[1]) || (String[1]==0))) {
:=// Checksums match, string ends in <cr> and address either matches or is 0
:=
:=startaddr=(string[3] & 0xF0)/16; // Shift right by 4
:=numbytes=(string[3] & 0x0F); // LS nibble
:=
:=switch (string[2]) {
:=// do some case statements in here...
:=}
:=}
:=
:=
:=The rest of my code works ok, it's the switching between the two comms that the PIC doesn't seem to like.
:=
:=Regards,
:=Darren

I had a similar requirement to use various I2C pins for a software driven master. What you should try is to define some routines for the low level I/O for both Rs232 and Rs485 as follows:

(This is just to show you the method I would use, you probably need to finish this off)

Also note this important section from the manual:

This directive tells the compiler the baud rate and pins used for serial I/O. This directive takes effect until another RS232 directive is encountered. The #USE DELAY directive must appear before this directive can be used. This directive enables use of built-in functions such as GETC, PUTC, and PRINTF.


#use rs232(baud=4800,parity=N,xmit=PIN_UTX,rcv=PIN_URX) // Select RS232 serial comms


char get_rs232(void)
{
char c;

c = getc(); // This getc will read from the software uart
return (c)
}

#use rs232 (baud=4800,parity=N,enable=PIN_RS485FLO,xmit=PIN_DI,rcv=PIN_RO)// Select RS485 serial comms

char get_rs485(void)
{
char c;

c = getc(); // This getc will read from the Hardware uart
return (c)
}

This idea should work, it's similar to what I did for the I2C and I even used the CCS I2C functions.


You can not use the method which you did:

if(comms==comm_rs232) {
#use rs232(baud=4800,parity=N,xmit=PIN_UTX,rcv=PIN_URX) // Select RS232 serial comms
}
else {
#use rs232 baud=4800,parity=N,enable=PIN_RS485FLO,xmit=PIN_DI,rcv=PIN_RO) // Select RS485 serial comms
}

Because #USE is a pre-processor directive.


Mark D'Sylva
___________________________
This message was ported from CCS's old forum
Original Post ID: 9978
darren logan
Guest







Re: Problems using 2 x serial ports
PostPosted: Wed Dec 11, 2002 1:29 pm     Reply with quote

"and I even used the CCS I2C functions" ...

...oooh MEEEOOOOW, saucer of milk for table 2?

8-)

Thank you for your reply. I do not understand the difference between a) what I have done (i.e. switch the comm ports conditionally) and b) use the RS232 pin definitions until another #use is encountered ?
Surely having #use RS232 configuration (a) on one line and then, #use RS232 configuration (b) on another line is just the same as switching between them conditionally ????
If it isn't, it should be !

The STREAM idea might work, though what makes my life slightly more complicated is that one port is software, the other is hardware. The software port needs to timeout using the KBHIT() function. The hardware doesn't need to time out as it is interrupt driven.

Still a little bit boggled.

Regards,
Darren
___________________________
This message was ported from CCS's old forum
Original Post ID: 9983
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

Re: Problems using 2 x serial ports
PostPosted: Wed Dec 11, 2002 1:34 pm     Reply with quote

:=Hello all,
:=
:=Im working with a PIC16F870 & PCM version 3.007.
:=
-----------------------------------------------------
If you are really using PCM vs. 3.007, and that's not a typo,
then the first thing you should do is upgrade the compiler.

For a while, CCS had an offer, where if you had a very early
version, they would allow you to upgrade to a working version
for free. If you're the registered owner, you should ask them
about that.
___________________________
This message was ported from CCS's old forum
Original Post ID: 9984
darren logan
Guest







Re: Problems using 2 x serial ports
PostPosted: Wed Dec 11, 2002 1:49 pm     Reply with quote

Upgrade to a working version !!!!!!

* GULP *
What does this mean ? all versions prior to 3.xxx do not work how one would expect them to ?

In your honest opinion, do you think that is the cause of my particular problem ?

This now begs the question:

Do I have a bug or is my programming not up to scratch ?

Regards,
Darren
___________________________
This message was ported from CCS's old forum
Original Post ID: 9985
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

Re: Problems using 2 x serial ports
PostPosted: Wed Dec 11, 2002 2:06 pm     Reply with quote

:=Upgrade to a working version !!!!!!
:=
:=* GULP *
:=What does this mean ? all versions prior to 3.xxx do not work how one would expect them to ?
----------------------------------

No. CCS has, effectively, two different compilers.
Version 2.xxx is different from 3.xxx. They each have
their own progression of "buggy" and "good" versions.

Version 3.xxx is the one that's available now.
I forget the exact version, but I think CCS considered that
vs. 3.045 was their first non-beta version. Later, this seemed
to have changed to vs. 3.068.
There may be some dispute over when it came out of "beta"
mode, but certainly, 3.007 is way, way, in BETA mode.

As far as your problem, it may be solvable. It might even
be easy to solve. But as soon as I saw "vs. 3.007", I didn't
even want to look at it. ...Just being truthful.
___________________________
This message was ported from CCS's old forum
Original Post ID: 9986
Mark DSylva
Guest







Re: Problems using 2 x serial ports
PostPosted: Wed Dec 11, 2002 7:09 pm     Reply with quote

:="and I even used the CCS I2C functions" ...
:=
:=...oooh MEEEOOOOW, saucer of milk for table 2?
:=
:=8-)
:=

I mentioned that I used the CCS functions because since I don't know how they are implemented, it's hard to predict how they may behave, so I was not sure if I could use them to communicate over the I2C when using various DATA lines and one single CLOCK line.


:=Thank you for your reply. I do not understand the difference between a) what I have done (i.e. switch the comm ports conditionally) and b) use the RS232 pin definitions until another #use is encountered ?
:=Surely having #use RS232 configuration (a) on one line and then, #use RS232 configuration (b) on another line is just the same as switching between them conditionally ????
:=If it isn't, it should be !

No it shouldn't, since the #use RS232 is setting up some values that are used by the pre-processor, not executed at run time.

:=
:=The STREAM idea might work, though what makes my life slightly more complicated is that one port is software, the other is hardware. The software port needs to timeout using the KBHIT() function. The hardware doesn't need to time out as it is interrupt driven.
:=
:=Still a little bit boggled.
:=
:=Regards,
:=Darren


Here is what I figure should work, I just cut and pasted quickly to show you this so it may not be perfect:
(note where I put the 2 #use rs232 directives)

int_timer2
timer2_isr() { // this counts in seconds

if(ticktime--==0) {
ticktime=17;
secs++;
// some other code in here, not worth printing
}
}

#use rs232(baud=4800,parity=N,enable=PIN_RS485FLO,xmit=PIN_DI,rcv=PIN_RO)// Select RS485 serial comms


#int_rda
rda_isr() { // RS485 serial char in service routine

string[RS485StrPointer]=getc(); // this getc is from h/w UART
if(string[RS485StrPointer]==':') {
RS485StrPointer=1;
}
else {
RS485StrPointer++;
if(RS485StrPointer==21) {
RS485StrPointer=0;
process_serial();
}
}
}

// any getc() after next line will use s/w UART

#use rs232(baud=4800,parity=N,xmit=PIN_UTX,rcv=PIN_URX)// Select RS232 serial comms




void main() {
int i;
char serin;
long adval;

initsys();

while(1) {

if(comms==comm_rs232) {
serin=timed_getc(); // timed_getc() times out after about 500mS
}
else {
delay_ms(400); // RS485 comms doesn't time out as it is hardware interrupt driven
}
// other code in here not worth printing
}

char timed_getc() {

long timeout;
int strpointer;

timeout=0;

while(!kbhit() && (++timeout<20000)) { // 200mS
delay_us(5);
}

if(kbhit()) {
string[0]=getc();
if(string[0]!=':') {
return(0);
}
else {
for(strpointer=1;strpointer<21;strpointer++) {
timeout=0;
while(!kbhit() && (++timeout<200)) {
delay_us(5);
}
if(kbhit()) {
string[strpointer]=getc();
}
else {
return(0); // timed out so return
}
}
// got all 21 characters
process_serial();
return('V'); // V for Valid string !
}
}
else {
return(0); // timed out so return
}
}

void process_serial(void) {

byte i,startaddr,numbytes;
byte checksum=0;
byte sysvals[6];

for(i=1;i<19;i++) {
checksum=(checksum ^ string[i]); // Exlusive OR 18 bytes to find checksum. 19th byte = checksum
}
/* String format / command definitions:

STRING: :aCsbbbbbbbbbbbbbbbm

: = start of string
a = address (0-31. All respond to 0)
C = command
s = start eeprom address (MS nibble), number of bytes to read/write (LS nibble)
b = bytes (tot. 15)
m = checksum (Xor of a,C,s and bytes)
= carriage return (end of string)

Command set:

W = write bytes
R = read bytes
r = read ALL live system values
*/

MyAddress=read_eeprom(16);

if(((checksum==string[19]) && (string[20]==13)) && ((MyAddress==String[1]) || (String[1]==0))) {
// Checksums match, string ends in and address either matches or is 0

startaddr=(string[3] & 0xF0)/16; // Shift right by 4
numbytes=(string[3] & 0x0F); // LS nibble

switch (string[2]) {
// do some case statements in here...
}
}

That will show you the general idea, but you may have other bugs...

Mark



___________________________
This message was ported from CCS's old forum
Original Post ID: 9988
dazlogan
Guest







Re: Problems using 2 x serial ports
PostPosted: Thu Dec 12, 2002 10:29 am     Reply with quote

Well I'm as poor as a church mouse at the moment.

All spent out on Xmas shopping.

So if someone out there is full of Xmas cheer and sends me an updated version of PCW I'd be forever greatful !!

8-)

(Only joking CCS)

Vbr,
Darren
___________________________
This message was ported from CCS's old forum
Original Post ID: 10002
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