Probléme LCD avec FPGA en VHDl

Fermé
lorre0041 Messages postés 8 Date d'inscription mercredi 1 avril 2009 Statut Membre Dernière intervention 28 juillet 2011 - 1 avril 2009 à 16:27
 insideFPGA - 16 avril 2009 à 16:27
Bonjour,
Je suis étudiant et je réalise un stage qui a pour sujet : "Conception et réalisation d'un télemetre à ultrasons" à base du FPGA Xilinx Spartan 3e-100. Je programme avec Xilinx ISE. je dois afficher les valeurs des mètres, decimètres et centimètres sur un afficheur lcd connecté sur les ports du FPGA. J'arrive bien à écrire ses valeurs et à les rafraichir mais pour rafraichir la valeur je dois réinitialiser le LCD en mode 4 bits à chaque fois.


architecture Behavioral of gestion_lcd is
signal ck1 : std_logic;
begin

process(clk)
variable count : integer;
begin
if clk='1' and clk'event then
count:= count+1;

--debut initialisation-----------------------------------------

if count = 280 then D <= x"3" ; RS <='0' ;end if;if count = 300 then ck1 <= not ck1; end if;if count = 301 then ck1 <= not ck1; end if; -- On force le lcd en 8 bits
if count = 330 then D <= x"3" ; RS <='0' ;end if;if count = 350 then ck1 <= not ck1; end if;if count = 351 then ck1 <= not ck1; end if; -- idem
if count = 380 then D <= x"3" ; RS <='0' ;end if;if count = 400 then ck1 <= not ck1; end if;if count = 401 then ck1 <= not ck1; end if; -- idem
if count = 402 then D <= x"2" ; RS <='0' ;end if;if count = 403 then ck1 <= not ck1; end if;if count = 404 then ck1 <= not ck1; end if; -- on passe en mode 4 bits
if count = 405 then D <= x"2" ; RS <='0' ;end if;if count = 406 then ck1 <= not ck1; end if;if count = 407 then ck1 <= not ck1; end if; -- mode 4 bits 1 lignes
if count = 408 then D <= x"0" ; RS <='0' ;end if;if count = 409 then ck1 <= not ck1; end if;if count = 410 then ck1 <= not ck1; end if; -- mode 4 bits 1 lignes
if count = 411 then D <= x"2" ; RS <='0' ;end if;if count = 412 then ck1 <= not ck1; end if;if count = 413 then ck1 <= not ck1; end if; -- mode 4 bits 2/4 lignes
if count = 414 then D <= x"8" ; RS <='0' ;end if;if count = 415 then ck1 <= not ck1; end if;if count = 416 then ck1 <= not ck1; end if; -- mode 4 bits 2/4 lignes
if count = 417 then D <= x"0" ; RS <='0' ;end if;if count = 418 then ck1 <= not ck1; end if;if count = 419 then ck1 <= not ck1; end if; -- afficheur on
if count = 420 then D <= x"C" ; RS <='0' ;end if;if count = 421 then ck1 <= not ck1; end if;if count = 422 then ck1 <= not ck1; end if; -- afficheur on
if count = 423 then D <= x"0" ; RS <='0' ;end if;if count = 424 then ck1 <= not ck1; end if;if count = 425 then ck1 <= not ck1; end if; -- efface memoire de données et curseur a 00h
if count = 426 then D <= x"1" ; RS <='0' ;end if;if count = 427 then ck1 <= not ck1; end if;if count = 428 then ck1 <= not ck1; end if; -- efface memoire de données et curseur a 00h
if count = 429 then D <= x"0" ; RS <='0' ;end if;if count = 430 then ck1 <= not ck1; end if;if count = 431 then ck1 <= not ck1; end if; -- deplacement vers la gauche
if count = 432 then D <= x"6" ; RS <='0' ;end if;if count = 433 then ck1 <= not ck1; end if;if count = 434 then ck1 <= not ck1; end if; -- deplacement vers la gauche

--ecriture debut ligne 1
if count = 625 then D <= x"8"; RS <='0' ;end if;if count = 626 then ck1 <= not ck1; end if;if count = 627 then ck1 <= not ck1; end if;
if count = 628 then D <= x"0"; RS <='0' ;end if;if count = 629 then ck1 <= not ck1; end if;if count = 630 then ck1 <= not ck1; end if;
--metre
if count = 631 then D <= met(7 downto 4); RS <='1' ;end if;if count = 632 then ck1 <= not ck1; end if;if count = 633 then ck1 <= not ck1; end if;
if count = 634 then D <= met(3 downto 0); RS <='1' ;end if;if count = 635 then ck1 <= not ck1; end if;if count = 636 then ck1 <= not ck1; end if;
--decimetre
if count = 643 then D <= deci(7 downto 4); RS <='1' ;end if;if count = 644 then ck1 <= not ck1; end if;if count = 645 then ck1 <= not ck1; end if;
if count = 646 then D <= deci(3 downto 0); RS <='1' ;end if;if count = 647 then ck1 <= not ck1; end if;if count = 648 then ck1 <= not ck1; end if;
--centimetre
if count = 655 then D <= cent(7 downto 4); RS <='1' ;end if;if count = 656 then ck1 <= not ck1; end if;if count = 657 then ck1 <= not ck1; end if;
if count = 658 then D <= cent(3 downto 0); RS <='1' ;end if;if count = 659 then ck1 <= not ck1; end if;if count = 660 then ck1 <= not ck1; end if;

if count = 1000 then count:=500;end if;
end process;
process(ck1)
begin
if ck1 ='0' then
E<='0';
end if;

if ck1 ='1' then
E<='1';
end if;
end process;
end Behavioral;


J'aimeraisavoir si quelqu'un aurait une idée de mon plobléme et si vous aviez un moyen de condenser mon programme qui est trés volumineux pour peu de code.
Merci d'avance pour toutes vos réponses.

2 réponses

lorre0041 Messages postés 8 Date d'inscription mercredi 1 avril 2009 Statut Membre Dernière intervention 28 juillet 2011
8 avril 2009 à 19:24
quelqu'un peut m aider? merci
0
Salut,
Il y a un probleme d'architecture, de design.
le mieux est de passer par une machine d'etat:
1 - reset
2 - initialisation de l'ecran lcd (mode, ...) suite a l'activation d'un pouton pousoir par exemple
3 - affichage de la valeur tous les x secondes (reste en boucle ici dans que ... condition a definir)


dans 1 process, ecrire un code permettant de mettre a jour la valeur a ecrire tous les x secondes.

dans 1 autre process, ecrire le code permettant l'ecriture sur l'ecran LCD



Salution,
0

Discussions similaires