pspsuceava Postat Octombrie 4, 2011 Partajează Postat Octombrie 4, 2011 Buna seara!Pana acuma am programat in ASM , insa vreau sa incep sa invat si ceva C, folosesc MPLAB + High tech C si nu gasesc un "macro" ( librarie ) buna si nu as vrea sa o folosesc tot pe cea din ASM . Daca are cineva una care sa aiba si configuratia pinilor cat mai usor de customizat .Multumesc mult !P.S.: Daca exista vreun compiler C mai bun ca asta dar atentie , FREE , astept pareri , multumesc .Din cautarile facute asta parea cel mai bun... Link spre comentariu
Liviu M Postat Octombrie 5, 2011 Partajează Postat Octombrie 5, 2011 Vezi in directorul in care ai instalat picc, subdirectorul samples/LCDemo, ar trebui sa gasesti o varianta minimala. Link spre comentariu
nooob64 Postat Octombrie 5, 2011 Partajează Postat Octombrie 5, 2011 O librarie pe care am scris-o in AVR32 studio ... se poate porta usor si pentru PIC doar modifici pinii unde sunt definiti . /* * lcd_driver.h * * Created on: Jul 14, 2010 * Author: noob64 */#include <stdarg.h>int s_contor=0;int s_end = 0;unsigned char s_count=0;#ifndef LCD_DRIVER_H_#define LCD_DRIVER_H_#define RS AVR32_PIN_PB12#define RW AVR32_PIN_PB13#define E AVR32_PIN_PB14#define DB4 AVR32_PIN_PB15#define DB5 AVR32_PIN_PB16#define DB6 AVR32_PIN_PB17#define DB7 AVR32_PIN_PB18#define LCD_BCKL AVR32_PIN_PB19#endif /* LCD_DRIVER_H_ */char lcd_buffer[21];void lcd_putchar(char c,unsigned char x,unsigned char y);//pune caracter la x,yvoid transferthedata (unsigned char data);//transfera datelevoid writecommand(unsigned char data);//scrie comanda la lcdvoid writedata(unsigned char data);//trimite comanda la lcdvoid init_lcd();//initializare lcdvoid write_char(char chr);//trimite caracter la lcd (fara pozitionare, se incrementeaza cursorul)void lcd_setup(unsigned char lcd , unsigned char bkl);//setare lcd on/off , bkl on/offvoid lcd_clear();//clear lcdvoid lcd_gotoxy(unsigned char x ,unsigned char y);//pozitionare cursor la x(coloana), y(linie)void lcd_puts(char *c,unsigned char x,unsigned char y);//pune string la x,yvoid lcd_delay();void scrolling_text(char *text,unsigned char x,unsigned char y,int delay); //afiseaza scrolling textunsigned char vector_init[]={12,0x03,0x03,0x03,0x02,0x02,0x0C,0x00,0x08,0x00,0x01,0x00,0x06};void transferthedata (unsigned char data){ if (data & 0x01) setbit(DB4); else if ( ! (data & 0x01) ) clrbit(DB4); if ( ( data >> 1 ) & 0x01 ) setbit(DB5); else if ( !(( data >> 1 ) & 0x01) ) clrbit(DB5); if ( ( data >> 2 ) & 0x01 ) setbit(DB6); else if ( !(( data >> 2 ) & 0x01) ) clrbit(DB6); if ( ( data >> 3 ) & 0x01 ) setbit(DB7); else if ( !(( data >> 3 ) & 0x01) ) clrbit(DB7);}void lcd_delay(){ cpu_delay_us(850,FOSC0_redef);}void writecommand(unsigned char data) { clrbit(E); clrbit(RS); clrbit(RW); transferthedata(data); setbit(E); lcd_delay(); clrbit(E); lcd_delay();//10ms }void writedata(unsigned char data) { clrbit(E); setbit(RS); clrbit(RW); transferthedata(data); setbit(E); lcd_delay(); clrbit(E); lcd_delay(); }void init_lcd(){ unsigned char i=0; delay_ms(30); for(i=1;i<=vector_init[0];i++) { writecommand(vector_init[i]); delay_ms(5); }}void write_char(char chr){ writedata(chr >> 4); writedata(chr);}void lcd_setup(unsigned char lcd , unsigned char bkl){ if(lcd == 1) { writecommand(0x00); writecommand(0x0C); //display on ; cursor , blink off } else { writecommand(0x00); writecommand(0x00); } if(bkl == 1) setbit(LCD_BCKL); else clrbit(LCD_BCKL);}void lcd_clear(){ writecommand(0x00); writecommand(0x01);}void lcd_gotoxy(unsigned char x ,unsigned char y){if(y==2){ writecommand(0x0C); //muta cursorul writecommand(0x00); //pe linia 2}if(y==1){ writecommand(0x00); //muta cursorul writecommand(0x02); //pe linia 1}while(x!=0){ writecommand(0x01); //muta cursorul writecommand(0x04); //in dreapta cu 1x--;}}void lcd_putchar(char c,unsigned char x,unsigned char y){ lcd_gotoxy(x,y); write_char(c);}void lcd_puts(char *c,unsigned char x,unsigned char y){ unsigned char i; lcd_gotoxy(x,y); for(i=0;i<strlen(c);i++) write_char(c[i]);}void long2lcd(unsigned long x,unsigned char z,unsigned char y){ unsigned long limita; unsigned char nrz; unsigned char fost; unsigned char r=0; limita=10000000; fost=0; while (limita>=10){ nrz=48; while (x>=limita){ x-=limita; nrz++; fost=1; } if (fost) { lcd_putchar(nrz,z+r,y); r++; } limita/=10; } lcd_putchar(x+48,z+r,y);}void nr2lcd(unsigned char c,unsigned char x,unsigned char y){ lcd_putchar(48+c/10,x,y); lcd_putchar(48+c%10,x+1,y);}void scrolling_text(char *text,unsigned char x,unsigned char y,int delay){unsigned char i;char to_lcd[21];s_count++;if(s_count == delay){s_end = strlen(text); for(i=0;i<=20;i++) { to_lcd[i] = text[i+s_contor]; } if(s_contor <= s_end-20) s_contor++; else s_contor = 0; lcd_puts(to_lcd,x,y); s_count =0;}}void lcd_printf(unsigned char x, unsigned char y, char *format, ...) { lcd_clear(); char buffer[21]; va_list args; va_start(args, format); vsprintf(buffer, format, args); lcd_puts(buffer, x, y); va_end(args);} Link spre comentariu
pspsuceava Postat Octombrie 6, 2011 Autor Partajează Postat Octombrie 6, 2011 Multumesc amandurora pentru sugestii ! Se poate inchide. Link spre comentariu
Postări Recomandate
Creează un cont sau autentifică-te pentru a adăuga comentariu
Trebuie să fi un membru pentru a putea lăsa un comentariu.
Creează un cont
Înregistrează-te pentru un nou cont în comunitatea nostră. Este simplu!
Înregistrează un nou contAutentificare
Ai deja un cont? Autentifică-te aici.
Autentifică-te acum