timotet 44 Posted October 30, 2012 Share Posted October 30, 2012 I got hardware SPI working with the Nokia 5110 LCD. I used a GPIO for the chip enable, and an interrupt for bringing CE high after transmission. I've attached the code below and a small graphics library that I put together from various sources on the web. One thing I found confusing was there seems to be no interrupt flag set when the SPITXBUF empties. So in the situation like this one where the Rx of the SPI is not even being used, to get the interrupt to work you still use the Rx ISR. Here is my interpretation: Write data to SPITXBUF data shifts through SPIDAT and is transmitted out SPISIMO, simultaneously the same data is shifted into SPIRXBUF and SPI INT FLAG is set. Then you use the Rx ISR to read the SPIRXBUF and that clears the SPI INT FLAG. Is this correct? Also the documentation on the FIFO is somewhat vague for the inexperienced. How would I go about using the FIFO for this example? Here is a short video: thanks Tim C2000_nokia5110.zip msptest6 1 Quote Link to post Share on other sites
msptest6 0 Posted October 30, 2012 Share Posted October 30, 2012 Thanks Tim! Looks quite good. Quote Link to post Share on other sites
emailcausey 0 Posted April 3, 2014 Share Posted April 3, 2014 I am a newbie. Trying to get the Nokia 5110 lcd to display text on the C2000. When I tried using this code I kept getting the error, "unresolved symbol _SPI_write8, first referenced in ./nokia5110.obj". Any idea why this would be? Thanks for posting your code. Hopefully I can get it to work! Quote Link to post Share on other sites
emailcausey 0 Posted April 3, 2014 Share Posted April 3, 2014 Would you mind attaching your wiring diagram? Still trying to get it to work. Quote Link to post Share on other sites
timotet 44 Posted April 13, 2014 Author Share Posted April 13, 2014 Hi You need to make sure the spi.h header file you are linking to contains the SPI_write8 function. If you look in your controlSUITE install the device support folder for the f2820x devices , latest version v220, f2802x_common, than the includes file, the spi.h file in there has the function you need. Either copy the function into the file you are linking to or replace the file with the newer one, then you should be good. I think the earlier contolSUITE was missing the SPI_write8 function for some reason. As far as the wiring look in the nokia5110.h file and the pin out is in the 1st few lines of code: #define nokiaVcc GPIO_Number_28 //connect to pin J1_3 on c2000 LP board #define nokiaSce GPIO_Number_34 //connect to pin J1_5 on c2000 LP board #define nokiaRst GPIO_Number_29 //connect to pin J1_4 on c2000 LP board #define nokiaDc GPIO_Number_4 //connect to pin J6_5 on c2000 LP board #define nokiaBlight GPIO_Number_5 //connect to pin J6_6 on on c2000 LP board #define nokiaMosi GPIO_Number_16 //connect to pin J6_7 on on c2000 LP board SPISIMOA #define nokiaClk GPIO_Number_18 //connect to pin J1_7 on on c2000 LP board SPICLK Hope this helps Tim Quote Link to post Share on other sites
emailcausey 0 Posted April 14, 2014 Share Posted April 14, 2014 Thank you for sending a very thoughtful response. Unfortunately even after I went through your comments I continued to have the error. Additionally, the warning says, "SPI_write8 declared implicitly." Do you think that I need to predefine a symbol (Project -> properties -> Build -> C2000 Compiler -> Advanced Options -> Predefined Symbols)? I read another post that used this tactic (http://www.forum.c2kcentral.com/topic/153-c2000-launchpad-timer0-problem/). Not certain what I would define it as. Any idea? Quote Link to post Share on other sites
emailcausey 0 Posted April 14, 2014 Share Posted April 14, 2014 Finally after going through and changing each spi.h file to the updated version...so that each one included the following lines of code at the bottom: //! \brief Writes a byte of data to the serial peripheral interface (SPI)//! \param[in] spiHandle The serial peripheral interface (SPI) object handle//! \param[in] data The data valueinline void SPI_write8(SPI_Handle spiHandle,const uint16_t data){ SPI_Obj *spi = (SPI_Obj *)spiHandle; // set the bits spi->SPITXBUF = (data & 0xFF) << 8; return; } // end of SPI_write() function I eliminated the SPI_Write8 error! Thanks a million Tim. However, I haven't seen the LCD come to life yet. Still troubleshooting. I will keep you posted. Quote Link to post Share on other sites
timotet 44 Posted April 14, 2014 Author Share Posted April 14, 2014 Well thats progress. I just posted in the other thread you created, so ignore that. We should probably keep it to one thread I think Tim Quote Link to post Share on other sites
emailcausey 0 Posted April 15, 2014 Share Posted April 15, 2014 My apologies for posting to the other thread. I will stick to this one. I realized after doing another tutorial (http://fortytwoandnow.blogspot.com/2012/08/c2000-piccolo-blinking-led.html)%C2'> I was missing one important component. I had deleted the 28027_RAM_lnk.cmd which made my LCD turn off as soon as I pressed "resume." This is an important based on the following lines of code: #ifdef _FLASH memcpy(&RamfuncsRunStart, &RamfuncsLoadStart, (size_t)&RamfuncsLoadSize); #endif However, after adding this command file back in I am now getting errors related to having available memory. I have attempted to eliminate unnecessary header files, but I think I am down to what is necessary. In addition to the default settings I have added: Project -> Properties -> Build -> C2000 Compiler -> Include Options "C:\ti\controlSUITE\device_support\f2802x\v210" Project -> Properties -> Build -> C2000 Linker -> File Search Path "C:\ti\controlSUITE\development_kits\C2000_LaunchPad\f2802x_common\lib\driverlib.lib" After reading the RAM cmd file I also tried adding the header linker command file (<base>\DSP2802x_headers\cmd) directly to the project, but that didn't seem to work. Ideas? Quote Link to post Share on other sites
timotet 44 Posted April 15, 2014 Author Share Posted April 15, 2014 Are you running this out of Flash or RAM? Project -> Properties -> Build configuration Flash [Active]. You need this linker cmd file: F2802x_generic_flash.cmd Browse to it from the Project CCS General tab at the bottom where it says linker command file. In ControlSUITE -> Development Kits -> C2000 Launchpad -> f2802x_common -> cmd fingers are crossed. Tim Quote Link to post Share on other sites
emailcausey 0 Posted April 16, 2014 Share Posted April 16, 2014 I checked Project -> Properties -> Build, but only found two options for configuration: “Debug” and “Release”. I am currently using Debug. I tried using "Release", but this action caused the include file "C:\ti\controlSUITE\device_support\f2802x\v210" in the Project Explorer to be removed, causing errors. I added F2802x_generic_flash.cmd into the Project Explorer (with the 28027_RAM_lnk.cmd simultaneously being in the Project Explorer). After pressing debug I received many errors, such as "#10263 BEGIN memory range has been exceeded" "#10264 #10264 ROM memory range overlaps" Based on the second error it occurred to me that maybe the 28027_RAM_lnk.cmd should be deleted and replaced with the F2802x_generic_flash.cmd. I did this and it debugged without error. However, when I pressed “resume” the backlight turned off and I also received a message, ‘Can't find a source file at “C:/controlsuite_gitorious_dev/device_support/f2802x/version/f2802x_common/source/F2802x_DefaultIsr.c" Locate the file or edit the source lookup path to include its location.' This is the exact same thing that was happening in the past when I deleted the “28027_RAM_lnk.cmd” from the Project Explorer, which makes me think that it is necessary to keep this file. I tried clicking "Locate File" and added a source folder to my desktop with the F2802x_DefaultIsr.c code inside. This didn’t do anything. Is F2802x_generic_flash.cmd necessary? I didn't use it in the simple blinking light example problem (http://fortytwoandnow.blogspot.com/2012/08/c2000-piccolo-blinking-led.html). Not really certain where to go from here. I might try deleting header files again. Any suggestions? Quote Link to post Share on other sites
emailcausey 0 Posted April 16, 2014 Share Posted April 16, 2014 AHA! Tim you were right again. After arduously trying to reduce the size by going through each header file...without success....I then decided to replace the 28027_RAM_lnk.cmd with F28028.cmd from C:\ti\controlSUITE\device_support\f2802x\v210\f2802x_common\cmd. Why this one works and the other doesn't....I don't know. But I'm going with it. I now have scrambling letters on my screen, but I am just happy to see something! Now to get that scrambled mess into a message. Will keep you posted. Quote Link to post Share on other sites
emailcausey 0 Posted April 17, 2014 Share Posted April 17, 2014 I changed the contrast writeCommand(0xC0); // Set LCD Vop (Contrast) and it is working very well. I really appreciate your responses. Thank you so much. Quote Link to post Share on other sites
emailcausey 0 Posted April 17, 2014 Share Posted April 17, 2014 Thanks for everything. timotet 1 Quote Link to post Share on other sites
timotet 44 Posted April 17, 2014 Author Share Posted April 17, 2014 Awesome!! Glad to help. 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.