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 CCS Technical Support

16f876a : sw uart dosn't work after new code added

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



Joined: 14 Jul 2004
Posts: 3

View user's profile Send private message

16f876a : sw uart dosn't work after new code added
PostPosted: Wed Jul 14, 2004 8:44 am     Reply with quote

Hello friends,

I'm using two sw uarts. the first works, the second too.

After placing some new code lines such these :

fprintf(AUX,"LED%d: GRÜN\n\rLED%d: GRÜN/GELB wechselnd\n\r",kanal*2+1,kanal*2+2);

into the source the received bytes from the second uart (func_modul) are corrupted. (Six byte has to come, only the first is ok.) If I remove the added lines, it work's again.

This are the first statements in the source:
#device *=16
#fuses noprotect,nodebug,nowrt,nocpd,nolvp,nobrownout,put,wdt,xt
#use delay(clock=4000000)
#use RS232 (BAUD = 1200,XMIT = PIN_C5,RCV = PIN_B1,PARITY = N,BITS = 8,BRGH1OK,stream = AUX)
#use RS232 (BAUD = 19200,XMIT = PIN_C7,RCV = PIN_C6,PARITY = N,BITS = 8,BRGH1OK,stream = FUNC_MODUL)


I really don't know whats wrong and I've already lost a lot of time.

May be somebody can help me.

Thanks.
Ttelmah
Guest







Re: 16f876a : sw uart dosn't work after new code added
PostPosted: Wed Jul 14, 2004 9:11 am     Reply with quote

alf-melmac wrote:
Hello friends,

I'm using two sw uarts. the first works, the second too.

After placing some new code lines such these :

fprintf(AUX,"LED%d: GRÜN\n\rLED%d: GRÜN/GELB wechselnd\n\r",kanal*2+1,kanal*2+2);

into the source the received bytes from the second uart (func_modul) are corrupted. (Six byte has to come, only the first is ok.) If I remove the added lines, it work's again.

This are the first statements in the source:
#device *=16
#fuses noprotect,nodebug,nowrt,nocpd,nolvp,nobrownout,put,wdt,xt
#use delay(clock=4000000)
#use RS232 (BAUD = 1200,XMIT = PIN_C5,RCV = PIN_B1,PARITY = N,BITS = 8,BRGH1OK,stream = AUX)
#use RS232 (BAUD = 19200,XMIT = PIN_C7,RCV = PIN_C6,PARITY = N,BITS = 8,BRGH1OK,stream = FUNC_MODUL)


I really don't know whats wrong and I've already lost a lot of time.

May be somebody can help me.

Thanks.

the BRGH setting only applies to the hardware UART.
I have to ask what else you would expect!.
If you are sending something like forty characters out the 'AUX' stream, This involves the processor being occupied doing this for about 32/100ths of a second. During this time, the software receive, cannot work.
You are trying to do more than this design is capable of achieving.
You can only really handle comms in one direction and one stream at a time, when using the software UARTs.

Best Wishes
alf-melmac



Joined: 14 Jul 2004
Posts: 3

View user's profile Send private message

PostPosted: Thu Jul 15, 2004 12:39 am     Reply with quote

I'm sorry, but may be I'didnt explain my problem correctly.
Ofcause I'm not sending and receiving at the same time !

This is the simplified program :

#use RS232 (BAUD = 1200,XMIT = PIN_C5,RCV = PIN_B1,PARITY = N,BITS = 8,stream = AUX)
#use RS232 (BAUD = 19200,XMIT = PIN_C7,RCV = PIN_C6,PARITY = N,BITS = 8,stream = FUNC_MODUL)

do {
stop_prog_and_wait_for_keystroke();
x=fgetc(FUNC_MODUL); // <- point of problem
if (x == wrong) show_error();

for (...) {
1) stop_prog_and_wait_for_keystroke();
do_something();
fprintf(AUX,......);

2) stop_prog_and_wait_for_keystroke();
do_something();
fprintf(AUX,......);

3) stop_prog_and_wait_for_keystroke();
do_something();
fprintf(AUX,......);
}
} while (1)


My probem :
If I add part 3) into the for-loop, the fgetc(FUNC_MODUL) d'snt work correcly anymore!

I think the increase of source lines changes the behavior of the generated code in "#uses rs232". (jump distance? bank switching ?)

Hope someone can help me.
alf-melmac



Joined: 14 Jul 2004
Posts: 3

View user's profile Send private message

PostPosted: Thu Jul 15, 2004 2:02 am     Reply with quote

I've got it.

There is a problem with long strings in the compiler:

d'snt work:
fprintf(AUX,"Drehschalter %d rechts:LED%d: GRÜN/links: LED%d: GELB.\n\r\n\r",kanal+1,kanal*2+1,kanal*2+2);

work:
fprintf(AUX,"Drehschalter %d rechts:LED%d: GRÜN/",kanal+1,kanal*2+1);
fprintf(AUX,"links: LED%d: GELB.\n\r\n\r",kanal*2+2);

Ok, let's go on (to the next bug).
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