Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Getkey + change UART
04-03-2012, 01:37 PM,
#11
RE: Getkey + change UART
Pinguino's keyword syntax should be as Java's one :
- first word, first letter : lower case
- second word and after, first letter : upper case
so getkey should be getKey.
I will fix it this afternoon.
Thank you.
It is easier to complain than it is to do, but it is better to do than it is to complain.
Reply
04-03-2012, 03:41 PM,
#12
RE: Getkey + change UART
Fixed in X.3 since rev. 296
Henk please, download X.3 from the svn repository :
Code:
svn checkout http://pinguino32.googlecode.com/svn/branches/x.3

(04-03-2012, 01:37 PM)regis Wrote: Pinguino's keyword syntax should be as Java's one :
- first word, first letter : lower case
- second word and after, first letter : upper case
so getkey should be getKey.
I will fix it this afternoon.
Thank you.

It is easier to complain than it is to do, but it is better to do than it is to complain.
Reply
05-03-2012, 04:35 PM,
#13
RE: Getkey + change UART
PinGuino: X.3 rev 296
OS: XP SP3
Board: PIC32 Pinguino Micro
Terminal: TeraTerm 4.67

Downloaded X.3 rev 296.
Adapted example "examples/4.communication/serial/getkey.pde" into:
Code:
void setup()
{
    Serial2.begin(9600);
}

void loop()
{
    u8 c;
    
    Serial2.printf("Please, press a key\n");
    c = Serial2.getKey();
    Serial2.printf("You pressed key [%c]\n",c);
}
"getKey" gives no response. Also, changing it into Serial1, no response.

(04-03-2012, 03:41 PM)regis Wrote: Fixed in X.3 since rev. 296
Henk please, download X.3 from the svn repository :
Code:
svn checkout http://pinguino32.googlecode.com/svn/branches/x.3

(04-03-2012, 01:37 PM)regis Wrote: Pinguino's keyword syntax should be as Java's one :
- first word, first letter : lower case
- second word and after, first letter : upper case
so getkey should be getKey.
I will fix it this afternoon.
Thank you.

Reply
05-03-2012, 04:44 PM,
#14
RE: Getkey + change UART
Hi Henk,
Can you replace :
Serial2.printf("You pressed key [%c]\n",c);
by :
Serial2.printf("You pressed key [%d]\n",c);
and tell me if you get 255 ?
It is easier to complain than it is to do, but it is better to do than it is to complain.
Reply
05-03-2012, 06:03 PM,
#15
RE: Getkey + change UART
Regis,
After the message "Please, press a key" the cursor goes one position down waiting for my keypress.
At the keypress nothing happens.
Reply
05-03-2012, 07:24 PM,
#16
RE: Getkey + change UART
Because your program never reach :
>> Serial2.printf("You pressed key [%c]\n",c);
the problem is then in serial.c/SerialGetKey() where the program can maybe not escape from this loop :
>> while (!(SerialAvailable(port)));
(just replace "return c" by "return 255" to check if I'm right).
which means that SerialGetDataBuffer() is never called,
which means on its turn that no RX interrupt occurs.

Hum ...

I use Serial2 on a PIC32-PINGUINO-OTG (same proc. as the Micro) to drive a Bluetooth module. Serial2 works (not yet the bluetooth library Wink) and I use a function which is quite the same as the internal SerialGetKey without problem ...

Anyone else to help on this ?




(05-03-2012, 06:03 PM)Henk van Beek Wrote: Regis,
After the message "Please, press a key" the cursor goes one position down waiting for my keypress.
At the keypress nothing happens.

It is easier to complain than it is to do, but it is better to do than it is to complain.
Reply
08-03-2012, 09:56 AM,
#17
RE: Getkey + change UART
PinGuino: X.3 rev 296
OS: XP SP3
Board: PIC32 Pinguino Micro
Terminal: TeraTerm 4.67

Problem Update :
While debugging the problem I discovered when I add a printf statement
in "SerialAvailable" in file "Serial.c", it all works well. I might be a simple printf statement but a SerialUART1WriteChar is not good enough.
I can't imagine what is going on here.[/code]

[code]/* ----------------------------------------------------------------------------
SerialAvailable
--------------------------------------------------------------------------*/

char SerialAvailable(u8 port)
{
SerialPrintf(UART1, "w=%d r=%d\r\n", UART1wpointer, UART1rpointer);

switch (port)
{
case UART1: return (UART1wpointer != UART1rpointer); break;
case UART2: return (UART2wpointer != UART2rpointer); break;
#ifdef ENABLE_UART3
case UART3: return (UART3wpointer != UART3rpointer); break;
#endif
#ifdef ENABLE_UART4
case UART4: return (UART4wpointer != UART4rpointer); break;
#endif
#ifdef ENABLE_UART5
case UART5: return (UART5wpointer != UART5rpointer); break;
#endif
#ifdef ENABLE_UART6
case UART6: return (UART6wpointer != UART6rpointer); break;
#endif
}
}


(05-03-2012, 07:24 PM)regis Wrote: Because your program never reach :
>> Serial2.printf("You pressed key [%c]\n",c);
the problem is then in serial.c/SerialGetKey() where the program can maybe not escape from this loop :
>> while (!(SerialAvailable(port)));
(just replace "return c" by "return 255" to check if I'm right).
which means that SerialGetDataBuffer() is never called,
which means on its turn that no RX interrupt occurs.

Hum ...

I use Serial2 on a PIC32-PINGUINO-OTG (same proc. as the Micro) to drive a Bluetooth module. Serial2 works (not yet the bluetooth library Wink) and I use a function which is quite the same as the internal SerialGetKey without problem ...

Anyone else to help on this ?




(05-03-2012, 06:03 PM)Henk van Beek Wrote: Regis,
After the message "Please, press a key" the cursor goes one position down waiting for my keypress.
At the keypress nothing happens.

Reply
08-03-2012, 10:28 AM,
#18
RE: Getkey + change UART
Probably the printf takes longer so what you really needed was a delay.

Many devices cannot cope with the 80MHz PIC32.

Usually timings are in the device data sheet, though they tend to specify them in a rather hostile manner.

John
Reply
08-03-2012, 11:28 AM,
#19
RE: Getkey + change UART
Ok pingotg,
I tried more "SerialUART1WriteChar"s. It needs 8 to work propely.
But I don't understand.
"SerialAvailable" is continously called. Maybe not the first time but after several times the write pointer must become different from the read pointer.
Reply
09-03-2012, 05:14 PM,
#20
RE: Getkey + change UART
PinGuino: X.3 rev 296
OS: XP SP3
Board: PIC32 Pinguino Micro
Terminal: TeraTerm 4.67

Update troubleshooting
I have appended two "SerialPrintf"-statements in the ISR "SerialGetDataBuffer" in file "serial.c":
Code:
    switch (port)
    {
        case UART1:
            caractere = U1RXREG;                            // read received char
            SerialPrintf(UART1, "Char=%c ", caractere);

            if (UART1wpointer != SERIAL1_BUFFERLENGTH - 1)    // if not last place in buffer
                newwp = UART1wpointer + 1;                    // place=place+1
            else
                newwp = 1;                                    // else place=1

            if (UART1rpointer != newwp)                        // if read pointer!=write pointer
                UART1SerialBuffer[UART1wpointer++] = caractere;    // store received char

            if (UART1wpointer == SERIAL1_BUFFERLENGTH)        // if write pointer=length buffer
                UART1wpointer = 1;                            // write pointer = 1

            SerialPrintf(UART1, "iw=%d   ir=%d\r\n", UART1wpointer,  UART1rpointer);
            //return UART1SerialBuffer;
            break;

        case UART2:
Which gave me at 3 times pressing the "h"-key:
Quote:Char=h iw=2 ir=1
Char=h iw=3 ir=1
Char=h iw=4 ir=1
Where "iw" stand for writepointer and "ir" for readpointer.

In the same file I appended in "SerialAvailable(u8 port)" the statement
to view if the writepointer moves:
Code:
//    SerialPrintf(UART1, "w=%d   r=%d\r\n", UART1wpointer,  UART1rpointer);
    if (UART1wpointer > 1)
        PORTESET=2;
    switch (port)
    {
        case UART1: return (UART1wpointer != UART1rpointer); break;
        case UART2:    return (UART2wpointer != UART2rpointer); break;
The writepointer doesn't move !.
Only when I uncomment the "SerialPrintf"-statement it works.
Unbelievable.
Please help !
(08-03-2012, 11:28 AM)Henk van Beek Wrote: Ok pingotg,
I tried more "SerialUART1WriteChar"s. It needs 8 to work propely.
But I don't understand.
"SerialAvailable" is continously called. Maybe not the first time but after several times the write pointer must become different from the read pointer.

Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)