Page 1 of 2

PIC16f874 project

PostPosted: Thu Dec 01, 2022 4:04 pm
by umogi_lvr
Dear Members! At university we were given the PIC16f874(-20/P), microcontroller shown in the picture, connected to an lcd display, and we were given the task to draw a logo on it. We've only learned similar things, but nothing like this, so we're having a lot of trouble getting the project done. We are using MPLab 6.0 and a program called pickit 2, into which we copy (or would copy, if we had it) the hex code from MPlab. So far, after much digging, we are trying the configuration bits, but no luck. Can anyone help? Suggest articles or anything. Also, if there is something I have not described, please let me know.

Re: PIC16f874 project

PostPosted: Fri Dec 02, 2022 2:45 am
by AussieSusan
Can you show us the code you have?
What has worked for you?
Can you program the MCU at all? If so can you do something like toggling a GPIO pin (the 'flash a LED' type task that shows you can get a very basic piece of code to work)
That LCD display looks like it is a graphics one - correct? If so do you have the data sheet for it so that you know how to initialise it and drive it correctly (they are sometimes not easy to get started)?
Looking at the solder joints to the display board, some seem to be 'dry'.
Susan

Re: PIC16f874 project

PostPosted: Fri Dec 02, 2022 11:06 am
by umogi_lvr
Thank you for your reply! After failing to configure the bits to run something, we are trying to start from the configuration of another microcontroller, I attach its code. I have not been able to find the type of the display nor the datasheet, but if I can get a pixel to show up that would be good enough.

Re: PIC16f874 project

PostPosted: Fri Dec 02, 2022 12:29 pm
by umogi_lvr
I found the display: "20-20056-3 Lcd models display"

Re: PIC16f874 project

PostPosted: Fri Dec 02, 2022 12:34 pm
by umogi_lvr
with this: EDT EW13B10GLY

Re: PIC16f874 project

PostPosted: Mon Dec 05, 2022 3:20 am
by AussieSusan
Are you able to show us the datasheet for the display? The ones that Ii can find on the web show the hardware interface but not the protocols for initialisation etc. that you have in your 'lcd.c' file - these are critical at getting most displays to work.
By the look of the code in 'lcd_init()' you are using the HD44780 protocol but that is for a character displays (often 2 or 4 rows by 16 to 20 character) and not a graphics display which I what I think you have. Are you sure that is correct (which is why I was asking for the initialisation protocol datasheet etc.)
You are using the HS oscillator and have set the _XTAL_FREQ preprocessor name, but are you really using a 4MHz crystal?
Personally I would not create separate files for the config and main includes - simply put the includes required in each C file and also put the config settings at the start of the main C file.
Further, you are right to use the "xc.h" file but I suspect the others are a waste of time - add them in later in the development cycle if needed. Don't include the 'p18cxxx.h' file - the "xc.h" does that for you better than doing it yourself.
Susan

Re: PIC16f874 project

PostPosted: Mon Dec 05, 2022 5:25 am
by ric
n.b. the PIC16f874 is a 14-bit core, so I have moved this topic from the 16 bit core forum to the 14 bit core forum.

Re: PIC16f874 project

PostPosted: Mon Dec 05, 2022 12:31 pm
by umogi_lvr
Thank you Susan for your help! There is a lot of redundancy in the code because I tried to use code from another project. The display is not as small as the code says. I have found the datasheet for the display.

The file is too big, so here's the link: https://datasheetspdf.com/pdf/550801/Em ... /EW13B10/1

Re: PIC16f874 project

PostPosted: Tue Dec 06, 2022 2:57 am
by AussieSusan
That was the only data sheet that I could find as well and it is totally useless for this purpose. It does not tell you anything about the signals you need to send to the display to initialise it or to write to it.
Copying files from different project scan make things harder for you than necessary. Just start from scratch and build things up slowly.
If the code does not match the display then your chances of getting it to work are negligible.
If the university gave you the display then ask them for the full data sheet that includes the communication protocols (not just the timing diagrams in the data sheet you linked)
Susan

Re: PIC16f874 project

PostPosted: Tue Dec 06, 2022 6:42 am
by ric