Codigo fuente
Upcoming SlideShare
Loading in...5
×
 

Codigo fuente

on

  • 723 views

 

Statistics

Views

Total Views
723
Views on SlideShare
689
Embed Views
34

Actions

Likes
0
Downloads
41
Comments
0

6 Embeds 34

http://micropic-project.blogspot.com 29
http://www.slideshare.net 1
http://www.blogger.com 1
http://micropic-electronic.blogspot.com 1
http://micropic-proyect.blogspot.com 1
http://www.micropic-project.blogspot.com 1

Accessibility

Categories

Upload Details

Uploaded via as Microsoft Word

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Codigo fuente Codigo fuente Document Transcript

  • #include<p18f2550.h><br />#include<delays.h><br />/**D E C L A R A C I O N D E F U N C I O N E S ***************************/<br />void send_col(unsigned char x);<br />void enviar_col(unsigned char C);<br />void envia_vector(unsigned char *V, unsigned char t);<br />void send_matriz(unsigned char *V,unsigned char M[8][8]);<br />void envia_matriz(unsigned char M[8][8], unsigned char t);<br />/**D E F I N I C I O N D E V A R I A B L E S *****************************/<br />#define PIN_CLOCK PORTAbits.RA4 // PORT for CLOCK //<br />#define TRIS_CLOCK DDRAbits.RA4 // TRIS for CLOCK //<br />#define PIN_CLEAR PORTAbits.RA5 // PORT for CLOCK //<br />#define TRIS_CLEAR DDRAbits.RA5 // TRIS for CLOCK //<br />#define PIN_DATA PORTAbits.RA1 // PORT for DATA //<br />#define TRIS_DATA DDRAbits.RA1 // TRIS for DATA //<br />/**D E C L A R A C I O N D E V A R I A B L E S G L O B A L E S *********/<br />unsigned char V_A[8] ={0b00111100,0b01111110,0b01100110,0b01100110,0b01111110,0b01111110,0b01100110,0b01100110};<br />unsigned char V_Nulo[8]={0,0,0,0,0,0,0,0};<br />void main (void)<br />{<br />/*************CONFIGURACION DE PUERTOR***************************/<br />ADCON1=0x0F;//Todos entrada/salida Digitales<br />TRISA=0; //Todos como salida<br />TRISB=0; //Todos como salida<br />PIN_CLEAR=1;//Si o Si para que la matriz entre en funcionamiento<br />PIN_CLOCK=0;<br />PORTB=0;<br />while(1)<br />{<br />envia_vector(V_A,50);<br />envia_vector(v_Nulo,50);<br />}<br />}<br />void send_col(unsigned char x)<br />{<br />if(x==0)<br />{PIN_DATA=0;}<br />else{PIN_DATA=1;}<br />Delay10TCYx(2);//retardo de 4 microsegundos<br />PIN_CLOCK=0;<br />Delay10TCYx(2);//retardo de 4 microsegundos<br />PIN_CLOCK=1;<br />}<br />void enviar_col(unsigned char C)<br />{<br />int i;<br />for(i=0;i<8;i++)<br />{<br />switch(i)<br />{<br />case 0: send_col(C & 0b00000001);break;<br />case 1: send_col(C & 0b00000010);break;<br />case 2: send_col(C & 0b00000100);break;<br />case 3: send_col(C & 0b00001000);break;<br />case 4: send_col(C & 0b00010000);break;<br />case 5: send_col(C & 0b00100000);break;<br />case 6: send_col(C & 0b01000000);break;<br />case 7: send_col(C & 0b10000000);break;<br />}<br />}<br />}<br />/*--------------------------------------------------------------------------------*/<br />//ENVIAR UNA VECTOR AL DISPLAY<br />void envia_vector(unsigned char *V, unsigned char t)//V:contiene el vector a enviar; t: tiempo de retencion de matriz en el display<br />{<br />unsigned char M_Aux[8][8];<br />send_matriz(V,M_Aux);<br />envia_matriz(M_Aux,t);<br />}<br />//FORMO MATRIZ A PARTIR DE VECTOR--------------------------------<br />void send_matriz(unsigned char *V,unsigned char M[8][8])<br />{<br />unsigned char i,j;<br />int Bits_Peso,aux;<br />for(i=0;i<8;i++)<br />{<br />Bits_Peso=1;<br />for(j=0;j<8;j++)<br />{<br />aux = V[i] & Bits_Peso;<br />if(aux!=0)<br />{<br />aux=1;<br />}<br />M[i][7-j]= aux;<br />Bits_Peso = Bits_Peso*2;<br />}<br />}<br />}<br />/*--------------------------------------------------------------------------------*/<br />//ENVIAR UNA MATRIZ AL DISPLAY<br />void envia_matriz(unsigned char M[8][8], unsigned char t)//M:contiene la matriz a enviar; t: tiempo de retencion de matriz en el display<br />{<br />unsigned char i,j,k,Col;<br />int D,Bits_Peso;<br />for(k=0;k<t;k++)//Tiempo de muestreo de letra<br />{for(j=0;j<8;j++)<br />{<br />Bits_Peso=1;<br />D=0;<br />for(i=8;i>0;i--)<br />{<br />if(M[i-1][j]==1)<br />{<br />D=D+Bits_Peso;<br />}<br />Bits_Peso=Bits_Peso*2;<br />}<br />switch(j)<br />{<br />case 0 : Col=0b10000000;break;<br />case 1 : Col=0b01000000;break;<br />case 2 : Col=0b00100000;break;<br />case 3 : Col=0b00010000;break;<br />case 4 : Col=0b00001000;break;<br />case 5 : Col=0b00000100;break;<br />case 6 : Col=0b00000010;break;<br />case 7 : Col=0b00000001;break;<br />}<br />PORTB=D;//Cargo el valor de las filas<br />enviar_col(~Col);//Cargo el valro de la columna en cuestion<br />Delay1KTCYx(35);//retardo de 2000 microsegundos<br />}<br />}<br />}<br />