cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Highlighted
7,516 Views
Registered: ‎11-27-2008

quesion1:how to display the string on the LCD

I would like to input  a string by the keyboard . Firstly  the  PICOBLAZE stored the string  in its internal register, and then let   LCD display the string, but the procedure does not seem to store  the characters in registers

Could you help me know what is wrong with my programe.

thanks

this is one part of my programe: the funcions :CALL LCD_cursor  CALL LCD_write_data  CALL delay_20ms are all right. But I find this programe can  not store the string into the internal register(address is 30H).   If you find someting wrong ,please give me some advices. Thanks                         

                  CONSTANT data_port, 01 ;

                  NAMEREG sF, UART_data

                  CONSTANT string_start, 30

                                                     

           warmstart: CALL receive_string

                     CALL LCD_reset

                     LOAD sE, string_start                                                               

                     LOAD s5,10

                     CALL LCD_cursor

                     FETCH s5, (sE)

                     CALL LCD_write_data

  

                     CALL delay_20ms

                    

                     ADD sE,01

                     LOAD s5,11

                     CALL LCD_cursor

                     FETCH s5, (sE)

                     CALL LCD_write_data

 

                     JUMP  warmstart

               

           

   receive_string: LOAD s1, string_start                  

                   LOAD s2, s1                           

                   ADD s2, 10

 

 receive_full_test:  INPUT UART_data, data_port

                     COMPARE UART_data, 00

                     JUMP Z, receive_full_test            

                     STORE UART_data, (s1)                 

                     COMPARE UART_data, character_CR      

                     RETURN Z

                     ADD s1, 01                            

                     COMPARE s1, s2 

                     JUMP NZ, receive_full_test            

                     RETURN

 

0 Kudos
5 Replies
Highlighted
Xilinx Employee
Xilinx Employee
7,496 Views
Registered: ‎09-05-2007

Your routine for writing to the LCD display does not contain a loop so at most it would appear to display only two characters. Assuming you are calling the LCD routines that I supplied with a Spartan Starter Kit then you are displaying the character stored at ‘string_start’ at the start of the first line and then displaying the character stored at ‘string_start+1’ in the second position of first line but then you stop. I think you need a loop that repeats until you reach a CR character or ‘string_start+10hex’ to do what you want. The LCD will automatically increment to the next character positions on the line as you display each character so you do not need to set the cursor position every time.

 

I do not know what your keyboard interface looks like but check that you are actually receiving ASCII values that can be displayed; you may need to convert them to ASCII yourself. Also ensure that your interface means that only one character is read at a time. It may be that you press a key and fill your buffer with the same character given how fast your program will execute.

 

Ken
Ken Chapman
Principal Engineer, Xilinx UK
0 Kudos
Highlighted
7,490 Views
Registered: ‎11-27-2008

I just want lcd to display the first and the second character ,so the programe is this. But the LCD doesn't  display anything, except  this character "||". 

So I would like to know that the inputed data is not stored into the memory, or others?

 

0 Kudos
Highlighted
Adventurer
Adventurer
7,476 Views
Registered: ‎02-26-2009

Do you have 8 LEDs or a uart output to verify, that the keyboard data is really what you expected??

 

 

 

bye

 

 

Klaus

 

0 Kudos
Highlighted
7,466 Views
Registered: ‎11-27-2008

I have 8 LEDs to verify, that the keyboard data is really what you expected.

So what should I do next?

thanks

0 Kudos
Highlighted
Adventurer
Adventurer
7,451 Views
Registered: ‎02-26-2009

Hi,

 

well, what you can do is to display the binary value of the received uart character on the leds.

So you had to connect the LEDs as peripheral to your system and assign it an address:

 

Example RTL code might roughly look like (I don't know your design and signal and clock names though)

wire led_sel;

reg [7:0] led_r;

`defiine LED_ADDRESS 8'h02

assign led_sel      = port_id       ==  `LED_ADDRESS;

assign LED = led_r;

 

 always @(posedge clk) begin
        if(write_strobe && led_sel) begin
            led_r <= out_port;
        end
    end
end

 

 

The SW to display the character that you typed would be

 

 

constant led_port,02

 

Then you can add in one test:

receive_full_test:  INPUT UART_data, data_port

                     COMPARE UART_data, 00

                     JUMP Z, receive_full_test            

                     STORE UART_data,(s1)                 

                     COMPARE UART_data, character_CR      

                     RETURN Z

                     OUTPUT UART_data, led_port ; now you should always 'see' the most recently typed

                    ; character that you read from your keyboard.

                     ADD s1, 01                            

                     COMPARE s1, s2 

                     JUMP NZ, receive_full_test            

                     RETURN

 

The SW to display the characters, that you send to the LCD would be.

           warmstart: CALL receive_string

                     CALL LCD_reset

                     LOAD sE, string_start                                                               

                     LOAD s5,10

                     CALL LCD_cursor

                     FETCH s5, (sE)

                     OUTPUT s5, led_port ; display first character

                     CALL LCD_write_data

  

                     CALL delay_20ms

                    

                     ADD sE,01

                     LOAD s5,11

                     CALL LCD_cursor

                     FETCH s5, (sE)

                     OUTPUT s5, led_port ; display second character

                     CALL LCD_write_data

 

                     JUMP  warmstart

 

 

So now a small example session:

- you start your system

- you press "A' on your keyboard and it should be sent via uart and read by picoblaze.

- if everything is configfured well 'A' you should now see the value 0x41 ('A') on the leds

  This would be equalto 0100 0001 so led 6 and led0 should be lit.

- you press 'B' and you should now see '0x42' or 0100 0010, which means led6 and led1 lit.

- Now you press 'CR'

- now the LED would display (too quickly to be seen) the value of 'CR' and the first character to be send to the LCD

- then it would display the second character to be send to the LCD, which should be 'B' or 0100 0010.

 

 

What could be your problems:

1.) bad character transmission from the keyboard.

This should now easily bi visible. The leds would diplay funny  / strange values like (all leds lit / all eds off or something strange)

 

2.) you do not no tstore the register from the uart at the same address where you read it from to display it at the LED

then the leds during typing should have correct values

and the led after typing return should have a crap value (perhaps 0000 0000 or 1111 1111)

if the latter is the case you could display sE or s1 on the LEDs instead of the received data / the data to be displayed.

 

 

Hope that gives some ideas

 

 

bye

 

 

Klaus

 

 

 

 

 

 

 

0 Kudos