[SOLVED] Replacing shiftOut with hard SPI
hello,
i'm tweaking nokia 5110 lcd's library adafruit more performance. so, want replace shiftout hardware spi.
the original working code :
(line 192 https://github.com/adafruit/adafruit-pcd8544-nokia-5110-lcd-library/blob/master/adafruit_pcd8544.cpp, shiftout alternative line 202)
so replace (i renamed library gamebuino_screen, don't care that)
and screen acts weirdly... here video :
http://www.youtube.com/watch?v=d6nlib_dlpk
the image moves right @ each frame.
something strange : if bridge pins dc & din (mosi) finger, image stops moving, menu's text not vertically aligned should.
so what's difference between software spi above , hardware spi ? please me
i'm tweaking nokia 5110 lcd's library adafruit more performance. so, want replace shiftout hardware spi.
the original working code :
code: [select]
inline void adafruit_pcd8544::fastspiwrite(uint8_t d) {
for(uint8_t bit = 0x80; bit; bit >>= 1) {
*clkport &= ~clkpinmask;
if(d & bit) *mosiport |= mosipinmask;
else *mosiport &= ~mosipinmask;
*clkport |= clkpinmask;
}
}
//a slower alternative :
inline void adafruit_pcd8544::slowspiwrite(uint8_t c) {
shiftout(_din, _sclk, msbfirst, c);
}(line 192 https://github.com/adafruit/adafruit-pcd8544-nokia-5110-lcd-library/blob/master/adafruit_pcd8544.cpp, shiftout alternative line 202)
so replace (i renamed library gamebuino_screen, don't care that)
code: [select]
void gamebuino_screen::begin(uint8_t contrast) {
spi.begin();
spi.setbitorder(msbfirst);
spi.setclockdivider(spi_clock_div64); //to have same clock speed "software" spi
spi.setdatamode(spi_mode3);
[...]
}
inline void gamebuino_screen::fastspiwrite(uint8_t d) {
spi.transfer((char)d);
}and screen acts weirdly... here video :
http://www.youtube.com/watch?v=d6nlib_dlpk
the image moves right @ each frame.
something strange : if bridge pins dc & din (mosi) finger, image stops moving, menu's text not vertically aligned should.
so what's difference between software spi above , hardware spi ? please me

Arduino Forum > Using Arduino > Programming Questions > [SOLVED] Replacing shiftOut with hard SPI
arduino
Comments
Post a Comment