Yes, I already thought about using the SPI module. The current bit-bang driver uses 14 words of memory and runs at ~190-kb/s (with 8-MHz clock). An SPI driver and its init code shouldn't be any bigger. I hope to work on an SPI driver later today. I just need to refresh my memory on the SPI modes. Looks like you're using CKE = 1 and CKP = 0, yes?
Implementing the 'packed' font table and extracting data was surprisingly simple, though I'm coding pretty close to the metal and the results are nothing as agile or elegant as your use of the 'readcode' function. Here's an excerpt, if you're interested;
Code:/******************************************************************** * * ********************************************************************/ void RdFlash() // bank 3 (inserted by compiler) { asm bcf _eecon1,CFGS // not 'config' memory |03 asm bsf _eecon1,EEPGD // select 'program' memory |03 asm bsf _eecon1,RD // initiate read operation |03 asm nop // required nop |03 asm nop // " |03 asm incf _eeadrl,F // bump EEADR |03 asm btfsc _status,Z // " |03 asm incf _eeadrh,F // " |03 asm rlf _eedatl,W // move b7 into Carry |03 asm rlf _eedath,W // wreg = the 7 bit hi byte |03 asm bcf _eedatl,7 // eedatl = the 7 bit lo byte |03 } // /******************************************************************** * * ********************************************************************/ void WrChar(char ascii) // WrChar() for packed 5x7 font { asm movf _ascii,W // ascii char value, 32..127 |00 asm addlw -32 // minus table offset |00 asm movwf _ascii // font array index, 0..95 |00 /* * * multiply index by 3 (0..95 -> 0..285), add table base address, * * and stuff the result in the EEADR register pair. * * */ asm lslf _wreg,W // wreg = (ascii-32)*2 |00 asm addwf _ascii,W // wreg = (ascii-32)*3 |00 // asm movlb 3 // bank 3 (inserted by compiler) |03 asm movwf _eeadrl // flash address lo |03 asm movlw 1024/256 // table address hi |03 asm btfsc _status,C // overflow? no, skip, else |03 asm addlw 1 // bump value |03 asm movwf _eeadrh // flash address hi |03 /* * * read 3 words (6 bytes) of font pattern data from the 5x7 font * * array and write them to the Nokia 5110 LCD. * * */ for(char i=0; i<3; i++) // { RdFlash(); // read one word (2 bytes) putlcd(wreg); // send hi byte putlcd(eedatl); // send lo byte } // } // /******************************************************************** * * ********************************************************************/ void WrChar(rom char *data) // overload function for strings { char ndx = 0; // while(data[ndx++]) // while not end-of-string WrChar(wreg); // } //Thank you again for sharing your work. MikeCode:/* * * initialize Nokia 5110 LCD display * * */ delay_ms(30); // rst = 0; // 5110 'reset' pulse rst = 1; // dc = 0; // command mode putlcd(0x20+0x01); // function set: extended instructions putlcd(0x80+0x30); // set Vop (contrast), 0..127 putlcd(0x04+0x02); // set temperature coefficient, 0..3 putlcd(0x10+0x03); // Set bias system, 0..7 putlcd(0x20+0x00); // function set: standard instructions putlcd(0x08+0x04); // display control: normal mode putlcd(0x80+0x20); // set DDRAM X address, 0..83 putlcd(0x40+0x02); // set DDRAM Y address, 0..5 dc = 1; // data mode WrChar("Hello"); // test string overload function




Bookmarks