??? 03/07/10 16:33 Read: times |
#173917 - Display problems |
I've been dabbling with a noritake VFD module with a HD47780 controller, and i cannot seem to get the letters to display properly. They are currently appearing on screen with a blank character inbetween each character i send to the screen so my code below should print Graeme but it is displayed as G r a e m e. Not only this but you will notice that the enable is strobed low then high, strobing the enable pin as usual does not print the character. I know the delays are completely inaccurate but this should not affect the display? surely only the speed at which i can send information to it. Also, I am not using the busy pin as I do not have a soldering iron to make a jumper to enable the busy pin. Im sure i am missing something blindingly obvious but after 6 hours of playing, I can get this to work, fresh out of ideas. Cheers for the helpful, and inciteful advice you always provide guys, Joel
#include <c8051f060.h> // SFR declarations #define SYSCLK 3062500 // approximate SYSCLK frequency in Hz found in slabs // example for this chip! i thought this was 24 500 000 ??? #define LCD_DATA P2 // set P2 alias sfr16 RCAP3 = 0xCA; // Timer3 reload value sfr16 TMR3 = 0xCC; // Timer3 counter sbit LED1 = P1^6; sbit RS = P3^3; //Register select sbit RW = P3^2; // Read write sbit EN = P3^1; //Enable //sbit B = P3^4; //unused sbit SW1 = P3^7; int a =1; void PORT_Init (void); // Initialised and configure port I/O void Timer3_Init (int counts); void Timer3_ISR (void); void Ext_Interrupt_Init (void); // Configure External Interrupts (/INT0 and /INT1) void hold (void); // Invokes constant never ending loop void delay (int t); // Delay void Screen_Init (void); // Calls screen initilisation funtion void send (char Hex, int RS_val); // sends byte 'char h' to screen void busy (void); // check busy flag on screen void oil_pressure (void); // write graphic of oil pressure warning light //------------------------------------------------------------------------------------ // MAIN Routine //------------------------------------------------------------------------------------ void main (void) { char string[1] = {'A'}; WDTCN = 0xde; WDTCN = 0xad; // disable watchdog timer Ext_Interrupt_Init (); // External interrupt initialisation Timer3_Init (SYSCLK / 12 / 10); // Initialise T3 PORT_Init (); // Port Direction Initialisation // Screen_Init (); // Initialise screen EA = 1; // enable global interrupts SFRPAGE = LEGACY_PAGE; while (1) { // P2= a; // delay(10); // EN = 1; // delay(10); // EN = 0; // a++; // send(0xF2,0); // send('B',1); // send(0xf0,0); // send(0x07,1); // send(0x07,1); send('G',0); send('r',0); send('a',0); send('e',0); send('m',0); send('e',0); hold(); //send (string[0], 1) SFRPAGE = CONFIG_PAGE; // set SFR page before reading writing P5 bits } // end main while loop } // end main void void send (char Hex, int RS_val) { char SFRPAGE_SAVE = SFRPAGE; SFRPAGE = CONFIG_PAGE; RS = RS_val; // correct RS val for command / data being sent delay(1000); EN = 0; // set enable high LCD_DATA = Hex; // send value to LCD data port delay(1000); // call delay with atleast 20ns EN = 1; // set enable low delay(1000); // call delay with atleast 100ns LCD_DATA = 0; // set LCD_PORT lines low for next data send delay(100000); //check busy? SFRPAGE = SFRPAGE_SAVE; } void PORT_Init (void) { char SFRPAGE_SAVE; SFRPAGE_SAVE = SFRPAGE; // Save old SFRPAGE SFRPAGE = CONFIG_PAGE; // Switch to configuration page XBR0 = 0x00; XBR1 = 0x14; // No peripherals selected 00010100 XBR2 = 0x40; // Enable crossbar and weak pullups EX0 = 1; // Enable /INT0 interrupts EX1 = 1; // Enable /INT1 interrupts P2MDOUT |= 0xff; // P1MDIN |= 0xFF; // P1.6 is digital - unnecessary as configured as 'digital' on reset P3MDOUT = 0xff; // P3 |= 0xF0; // Set P3.7-P3.4 latch to '1' P1MDOUT = 0x40; //(LED) // P0 = 0xFF; //P3 = 0xff; //P2 = 0xff; LED1 = 0; // Init LED1 to 0 SFRPAGE = SFRPAGE_SAVE; // to previous } void Screen_Init (void) { char SFRPAGE_SAVE = SFRPAGE; SFRPAGE = CONFIG_PAGE; send(0x30, 0); // Luminescence command send(0x03, 1); // Luminescence value (100%) SFRPAGE = SFRPAGE_SAVE; } void Ext_Interrupt_Init (void) { char SFRPAGE_SAVE = SFRPAGE; SFRPAGE = TIMER01_PAGE; TCON = 0x05; // /INT 0 and /INT 1 are falling edge triggered EX0 = 1; // Enable /INT0 interrupts EX1 = 1; // Enable /INT1 interrupts SFRPAGE = SFRPAGE_SAVE; } void Timer3_Init (int counts) { char SFRPAGE_SAVE = SFRPAGE; SFRPAGE_SAVE = SFRPAGE; SFRPAGE = TMR3_PAGE; // T3 Page TMR3CN = 0x00; // Stop Timer3; Clear TF3; // use SYSCLK/12 as timebase RCAP3 = -counts; // Init reload values TMR3 = 0xffff; // set to reload immediately EIE2 |= 0x01; // enable Timer3 interrupts TR3 = 1; // start Timer3 SFRPAGE = SFRPAGE_SAVE; } void oil_pressure (void) { char oilpressure[2][36]={0x1c,0x66,0x42,0x43,0x61,0x31,0x1b,0x0e,0x04,0x04, 0x14,0x14,0x14,0x1d,0x1d,0x14,0x14,0x14,0x04,0x02, 0x01,0x01,0x02,0x02,0x04,0x04,0x04,0x08,0x08,0x09, 0x13,0x16,0x2c,0x30,0x03,0x01,0x00,0x00,0x00,0x00, 0x00,0x80,0xfe,0x02,0x02,0x02,0x02,0x02,0x02,0xea, 0xea,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x06, 0x0c,0x18,0x30,0x60,0xc0,0x80,0x00,0x00,0x00,0x00, 0xc0,0xc0}; int r, c; for (r=0;r<2;r++) { //call function to set cursor back to for (c=0;c<36;c++) { //call send(oilpressure[r][c]); } } } void delay (int t) { while(t!=0) t--; } void hold (void) { while(1); } void busy (void) { // must check the busy status, R/W = H, RS = L, check bit D7 high, must configure port direction and strong pull ups? } void Timer3_ISR (void) interrupt 14 { TF3 = 0; // clear TF3 LED1 = ~LED1; // change state of LED } //void INT0_ISR (void) interrupt 1 //{ // //} //void INT1_ISR (void) interrupt 0 //{ // //} |
Topic | Author | Date |
Display problems | 01/01/70 00:00 | |
forgot to mention! | 01/01/70 00:00 | |
read the datasheet and buy the iron | 01/01/70 00:00 | |
just a minute ... | 01/01/70 00:00 | |
If you can't "afford" the one pin for the R/W signal | 01/01/70 00:00 | |
Why not address his question instead of wasting more money? | 01/01/70 00:00 | |
odd behaviour | 01/01/70 00:00 | |
Magic? | 01/01/70 00:00 | |
oscilloscope is fine, but in this case... | 01/01/70 00:00 | |
Both, I think | 01/01/70 00:00 | |
"magic" is synonym for "luck" | 01/01/70 00:00 | |
working | 01/01/70 00:00 | |
min & max limits | 01/01/70 00:00 | |
Delay lengths | 01/01/70 00:00 | |
If only folks would do what we once always did ...![]() | 01/01/70 00:00 | |
RW pin is defined but | 01/01/70 00:00 |