Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Getkey + change UART
09-03-2012, 05:20 PM,
#21
RE: Getkey + change UART
Hi Henk,
Is it not a problem to use SerialPrintf in SerialAvailable as SerialPrintf uses SerialAvailable ?
I'd rather use CDCprintf instead to debug the code.
Régis
It is easier to complain than it is to do, but it is better to do than it is to complain.
Reply
10-03-2012, 08:07 PM,
#22
RE: Getkey + change UART
Regis,
In this particular case it was more convenient debugging this way.
And, no: "SerialAvailable" is only used by "getkey".
I have checked both addresses of uart1wpointer in ISR and in "SerialAvailable" and they are the same. In the ISR it is increased. In"SerialAvailable" it is not, it remains 1.
(09-03-2012, 05:20 PM)regis Wrote: Hi Henk,
Is it not a problem to use SerialPrintf in SerialAvailable as SerialPrintf uses SerialAvailable ?
I'd rather use CDCprintf instead to debug the code.
Régis

Reply
10-03-2012, 08:47 PM,
#23
RE: Getkey + change UART
Henk,

Open the serial.c file and add 'volatile' for all the variables used in the interrupt routine:
I tested before and after and it seems to be OK.

JP

volatile char UART1SerialBuffer[SERIAL1_BUFFERLENGTH]; // UART1 buffer
volatile char UART2SerialBuffer[SERIAL2_BUFFERLENGTH]; // UART2 buffer
#ifdef ENABLE_UART3
volatile char UART3SerialBuffer[SERIAL3_BUFFERLENGTH]; // UART3 buffer
#endif
#ifdef ENABLE_UART4
volatile char UART4SerialBuffer[SERIAL4_BUFFERLENGTH]; // UART4 buffer
#endif
#ifdef ENABLE_UART5
volatile char UART5SerialBuffer[SERIAL5_BUFFERLENGTH]; // UART5 buffer
#endif
#ifdef ENABLE_UART6
volatile char UART6SerialBuffer[SERIAL6_BUFFERLENGTH]; // UART6 buffer
#endif

volatile long UART1wpointer, UART1rpointer; // write and read pointer
volatile long UART2wpointer, UART2rpointer; // write and read pointer
#ifdef ENABLE_UART3
volatile long UART3wpointer, UART3rpointer; // write and read pointer
#endif
#ifdef ENABLE_UART4
volatile long UART4wpointer, UART4rpointer; // write and read pointer
#endif
#ifdef ENABLE_UART5
volatile long UART5wpointer, UART5rpointer; // write and read pointer
#endif
#ifdef ENABLE_UART6
volatile long UART6wpointer, UART6rpointer; // write and read pointer
#endif

(10-03-2012, 08:07 PM)Henk van Beek Wrote: Regis,
In this particular case it was more convenient debugging this way.
And, no: "SerialAvailable" is only used by "getkey".
I have checked both addresses of uart1wpointer in ISR and in "SerialAvailable" and they are the same. In the ISR it is increased. In"SerialAvailable" it is not, it remains 1.
(09-03-2012, 05:20 PM)regis Wrote: Hi Henk,
Is it not a problem to use SerialPrintf in SerialAvailable as SerialPrintf uses SerialAvailable ?
I'd rather use CDCprintf instead to debug the code.
Régis

Reply
10-03-2012, 09:32 PM,
#24
RE: Getkey + change UART
JP,
Yes, you're right. That was the bug.
I have now studied the attribute "volatile" and fully understand the meaning.
I was desperate for not understanding the error.
Even now I understand why it worked when I inserted a few other statements in front of the statement retrieving "UART1wpointer".

Thank you very much !!
Problem solved and closed.

Henk
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)