cde 334 Posted October 11, 2013 Share Posted October 11, 2013 I got my LCD working, after fixing some bonehead mistakes (Like setting the main data for loop with I = 8; I < 8, so no data ever got clocked out). Once I wired it up correctly, it shows my image and loops a few strings, clears, everything. But I cannot get it working unless I drive the SCE/CS pin directly. If I tie it to ground, it refuses to start up or anything. void nokia_init(void) { // Initialize Pins P1SEL &= ~SCE & ~RES & ~DC & ~SDIN & ~SCLK; // Set Needed Pins as GPIO (Part 1) P1SEL2 &= ~SCE & ~RES & ~DC & ~SDIN & ~SCLK; // Set Needed Pins as GPIO (Part 2) P1OUT |= SCE | RES | DC | SDIN | SCLK; // Set Needed Pins to High P1DIR |= SCE | RES | DC | SDIN | SCLK; // Set Needed Pins as Outputs // Enable Nokia Display DISPLAY_PORT &= ~SCE; // Set Chip Select Low, Unused // Reset LCD DISPLAY_PORT |= RES; // Pull Reset High to Known State, Probably Unneeded DISPLAY_PORT &= ~RES; // Pull Reset Low to Reset LCD DISPLAY_PORT |= RES; // Pull Reset High to Complete Reset // Cycle Clock // DISPLAY_PORT &= ~SCLK; // Pull SPI Clock Low // DISPLAY_PORT |= SCLK; // Pull SPI Clock High // Disable Nokia Display DISPLAY_PORT |= SCE; // Set Chip Select High // Setup Nokia Display nokia_write( 0x21, SEND_CMD ); // LCD On, H addressing, Ext. Commands. nokia_write( 0xBf, SEND_CMD ); // Set LCD VOP (Contrast). nokia_write( 0x06, SEND_CMD ); // Set Temp Coefficient to 2. nokia_write( 0x13, SEND_CMD ); // LCD Bias Mode 1:48 nokia_write( 0x20, SEND_CMD ); // LCD On, H addressing, Stnd. Commands. nokia_write( 0x08, SEND_CMD ); // LCD Display Blanked. nokia_write( 0x0C, SEND_CMD ); // LCD Display Set to Normal Mode. nokia_clear(6); // Clear Screen } Can anyone see why it won't work when the SCE line is tied to ground? (attached is the entire project files so far (2x .c, 2x .h). Update: (Solution as per oPossum, add delay between and after, Pulling Reset Pin Low and High) Fridge.zip Quote Link to post Share on other sites
cubeberg 540 Posted October 11, 2013 Share Posted October 11, 2013 Connected directly to ground, or through a resistor? You need a pull-down. Quote Link to post Share on other sites
cde 334 Posted October 11, 2013 Author Share Posted October 11, 2013 Connected directly to ground, or through a resistor? You need a pull-down. Directly. Why would a pull-down make a difference in this case? When the msp drives the pin low, it's essentially a direct connection as well, no? Quote Link to post Share on other sites
oPossum 1,083 Posted October 11, 2013 Share Posted October 11, 2013 Try adding some delays to reset. // Reset LCD DISPLAY_PORT |= RES; // Pull Reset High to Known State, Probably Unneeded DISPLAY_PORT &= ~RES; // Pull Reset Low to Reset LCD __delay_cycles(100000); DISPLAY_PORT |= RES; // Pull Reset High to Complete Reset __delay_cycles(100000); cde 1 Quote Link to post Share on other sites
cubeberg 540 Posted October 11, 2013 Share Posted October 11, 2013 Right, but when you pull the pin high - it's just dumping to ground. Quote Link to post Share on other sites
cde 334 Posted October 11, 2013 Author Share Posted October 11, 2013 Right, but when you pull the pin high - it's just dumping to ground. No, the point is that I don't have to pull the pin high or low. It gets tied to ground at the board and saves a pin. Quote Link to post Share on other sites
cubeberg 540 Posted October 11, 2013 Share Posted October 11, 2013 No, the point is that I don't have to pull the pin high or low. It gets tied to ground at the board and saves a pin. Ah - ok - didn't think about that - you still had code in pulling the line high. In that case - oPossum probably has the right answer. Quote Link to post Share on other sites
spirilis 1,264 Posted October 11, 2013 Share Posted October 11, 2013 Do LCDs like this typically require the CS pin to be used as a "signal" for start-of-command and end-of-data type of stuff? I always thought they did, i.e. you can't just hold CS low forever and expect the I/O to work right. cubeberg 1 Quote Link to post Share on other sites
oPossum 1,083 Posted October 11, 2013 Share Posted October 11, 2013 CS will enforce SPI sync. If CS is not used then you must make sure the SPI clock is perfect. If the LCD has not fully reset when SPI comms begin, then sync is messed up. roadrunner84 and cde 2 Quote Link to post Share on other sites
cde 334 Posted October 11, 2013 Author Share Posted October 11, 2013 Do LCDs like this typically require the CS pin to be used as a "signal" for start-of-command and end-of-data type of stuff? I always thought they did, i.e. you can't just hold CS low forever and expect the I/O to work right. From what every source says, (Serdisplib, sparkfun, adafruit) you should be able to. Like a standard SPI device, if it's the only one on the bus, you should be able to tie the CS to ground. Quote Link to post Share on other sites
cde 334 Posted October 11, 2013 Author Share Posted October 11, 2013 Try adding some delays to reset. // Reset LCD DISPLAY_PORT |= RES; // Pull Reset High to Known State, Probably Unneeded DISPLAY_PORT &= ~RES; // Pull Reset Low to Reset LCD __delay_cycles(100000); DISPLAY_PORT |= RES; // Pull Reset High to Complete Reset __delay_cycles(100000); This did it. I used a smaller delay, but it worked on the first try. Funny, I actually had those delays in it, but due to some wiring and bugs in the code, I had removed them. Ah you know what they say about second guessing yourself. Thanks oPossum. Quote Link to post Share on other sites
spirilis 1,264 Posted October 11, 2013 Share Posted October 11, 2013 Ah k, this has a D/C pin which I guess enforces the data vs command part. Sent from my Galaxy Note II with Tapatalk 4 Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.