Jump to content
  • 0

Keyboard input problem - zybo buffer


Andrea_cau

Question

Hi,
I use zybo board and I want to modify HDMI_IN project.
https://reference.digilentinc.com/learn/programmable-logic/tutorials/zybo-hdmi-demo/start

I have created a black square in the screen (static image) and other simple modifications.
The first problem that I want to solve is this:
when I type '1' to change resolution, '1' and 'ENTER' are stored into the buffer and read by board. ENTER is seen as '/r','/n' and for this reason is displayed 2 times 'invalid selection' 
this is a part of the code
        while (!fResSet)
        {
        DemoCRMenu();

        
        /* Wait for data on UART */
        while (!XUartPs_IsReceiveData(UART_BASEADDR))
        {}

        /* Store the first character in the UART recieve FIFO and echo it */
        userInput = XUartPs_ReadReg(UART_BASEADDR, XUARTPS_FIFO_OFFSET);
        /*FIRST MOD*/
        .
        /*first part of code*/
        .
        switch (userInput)
        {
            .
            .
            /*second part of code*/
            .
            
        default :
            xil_printf("\n\rInvalid Selection");
            TimerDelay(500000);
        }
        }
At the first I try to solve it replacing the SWITCH-CASE and modifying the condition (userInput !='\n' etc) , but this not resolve the problem.
then I try to solve it flushing the UART FIFO when I wrote /*FIRST MOD*/ but this not solve the problem. 

this is the code for flush UART FIFO
    /* Flush UART FIFO */
    while (XUartPs_IsReceiveData(UART_BASEADDR))
    {
        XUartPs_ReadReg(UART_BASEADDR, XUARTPS_FIFO_OFFSET);
    }

can you help me?
Andrea

Link to comment
Share on other sites

7 answers to this question

Recommended Posts

It would probably be easier to just switch to something like Tera Term, see the link I provided above. Our demos are validated with Tera Term, rather than the SDK console.

It is possible that the flush cache doesn't see the '\r\n' until after it has already continued to the change res function. If this is the case, instead of flushing, you may need to call something like the following:

int n=0;
while (n<2) {
    n += Uart_Receive(...);
}

This will make sure to pick up the two newline characters.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...