|
|
View previous topic :: View next topic |
Author |
Message |
lola
Joined: 08 Dec 2003 Posts: 3
|
Problems with the funktion putc()! |
Posted: Mon Jan 26, 2004 1:24 pm |
|
|
After printing 17 times a charakter ( putc('I') ) my program is not able to get charakters correkty.
If i am printing only two times, it works correktly.
putc('H');
putc('E');
.
.
.
putc('O');
A = getc();
B = getc();
C = getc();
O = getc(); |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Jan 26, 2004 2:05 pm |
|
|
Post a complete sample program that demonstrates the problem.
Post the #use rs232 statement, the #fuses statement, #use delay
statement, etc. (ie, the complete program).
Also post the type of PIC that you're using and the version of
the compiler. |
|
|
lola
Joined: 08 Dec 2003 Posts: 3
|
|
Posted: Tue Jan 27, 2004 6:04 am |
|
|
This program works very well until you remove the documentation in funktion BT_Inquire(void).
It seems to me that something in the write stack of the rs232 overwrites something in the read stack, or may be some flag is set.
headerfile:
#ifndef __SPIROMETER__
#define __SPIROMETER__
#include <16F76.h>
#device *=16
#use delay(clock=10000000)
#fuses NOWDT,HS,NOPUT,NOPROTECT,NOBROWNOUT
#use rs232(baud=14400,xmit=PIN_C6,rcv=PIN_C7)
#endif
C-file:
#include "76test2.h"
void BT_Inquire(void) //AT+BINQ=0,0,5,10\r\n
{
putc('A');
putc('T');
putc('+');
putc('B');
/*putc('I'); // if you remove the documentation
putc('N'); // the funktion GetAddress() will not work
putc('Q');
putc('=');
putc('0');
putc(',');
putc('0');
putc(',');
putc('5');
putc(',');
putc('1');
putc('0');
putc('\r');
putc('\n');*/
}
#inline
int GetAddress()
{
volatile char answe[29];
int wartezeit = 16;
timer_starten(); //TimeOut Timer Start
do {
if (kbhit()==0x01)
{
answe[0] = answe[1];
answe[1] = answe[2];
answe[2] = answe[3];
answe[3] = answe[4];
answe[4] = answe[5];
answe[5] = answe[6];
answe[6] = answe[7];
answe[7] = answe[8];
answe[8] = answe[9];
answe[9] = answe[10];
answe[10] = answe[11];
answe[11] = answe[12];
answe[12] = answe[13];
answe[13] = answe[14];
answe[14] = answe[15];
answe[15] = answe[16];
answe[16] = answe[17];
answe[17] = answe[18];
answe[18] = answe[19];
answe[19] = answe[20];
answe[20] = answe[21];
answe[21] = answe[22];
answe[22] = answe[23];
answe[23] = answe[24];
answe[24] = answe[25];
answe[25] = answe[26];
answe[26] = answe[27];
answe[27] = answe[28];
answe[28] = getc();
}
}while((sekunden < wartezeit) && !(answe[26]=='L' && answe[27]=='E' && answe[28]=='D'));
timer_stop();
if (sekunden == wartezeit)
{
return 0x00; //Timeout
}
else
{
return 0x01;
}
void main()
{
int Error = 0x00;
BT_Inquire();
BT_Inquire();
BT_Inquire(); //printf("AT+BINQ=0,0,5,10\r\n");
Error=GetAddress();
if (Error!=1)
Reset();
} |
|
|
Neutone
Joined: 08 Sep 2003 Posts: 839 Location: Houston
|
|
Posted: Tue Jan 27, 2004 8:26 am |
|
|
It's kind of a side issue but you can use an entire string with puts(). It is actually documented in the compiler manual. |
|
|
Humberto
Joined: 08 Sep 2003 Posts: 1215 Location: Buenos Aires, La Reina del Plata
|
|
Posted: Tue Jan 27, 2004 8:45 am |
|
|
I had similar issue when the modem generated a kind of glitches in the Tx line while I was transmiting.
Anyway I don�t see where you handle the UART interrupts.
Try with this:
Code: |
void BT_Inquire(void) //AT+BINQ=0,0,5,10\r\n
{
disable_interrupts(GLOBAL);
printf("AT+BINQ=0,0,5,10\r\n");
enable_interrupts(GLOBAL);
}
|
Regards,
Humberto |
|
|
|
|
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
|