Page 2 of 2

Re: PIC16f874 project

PostPosted: Tue Dec 06, 2022 12:54 pm
by umogi_lvr
Again, thank you very much for your help. The display is theoretically a completely generic graphics lcd, so it doesn't need a specific datasheet (although I don't fully understand this). I've started a completely basic code (attached). In addition, I have the code for the logo to be drawn.

Re: PIC16f874 project

PostPosted: Tue Dec 06, 2022 2:23 pm
by umogi_lvr
Update: I made a diagram of which bit of the microcontroller is connected to which bit of the lcd. I found a project where a pic16f877 is used to do this (image display on GLCD).

Re: PIC16f874 project

PostPosted: Wed Dec 07, 2022 5:22 am
by ric
umogi_lvr wrote:The display is theoretically a completely generic graphics lcd,

There is no such thing.
so it doesn't need a specific datasheet (although I don't fully understand this).

You are quite justified in not understanding this, because it is rubbish.
Whoever said this does not know what they are talking about.

Re: PIC16f874 project

PostPosted: Wed Dec 07, 2022 5:27 am
by ric
umogi_lvr wrote:Update: I made a diagram of which bit of the microcontroller is connected to which bit of the lcd. I found a project where a pic16f877 is used to do this (image display on GLCD).

That project is flipping the connections on the data bus.
i.e. RD7 -> D0
RD6 -> D1

That may have made someone's PCB layout simpler, but will make the software more complex.

Re: PIC16f874 project

PostPosted: Wed Dec 07, 2022 5:50 am
by AussieSusan
That makes more sense but I still think you may not be initialising it correctly - you MUST obey the minimum delays between some of the commands.
Look for the data on the web about how to initialise these controllers.
Susan

Re: PIC16f874 project

PostPosted: Wed Dec 07, 2022 5:58 am
by ric
Now I look closer at the photo in your first post, the two large chips that don't have a sticker over them are plainly "KS0108B".
Those chips can only drive a 64x64 matrix, so it takes two of them to drive a 128x64 display.
You will be talking to one chip when the "CS1" signal is driven active, and the other chip when "CS2" is active.
The chip with the sticker on it is almost certainly a KS0107B. You can see how it is used on the application circuit shown on page 10 of the KS0108B datasheet.
The microcontroller does not communicate with the KS0107B, so you don't need to worry about it.

Re: g16f874 project

PostPosted: Thu Dec 08, 2022 5:12 pm
by umogi_lvr
Again, thank you very much for your help, as tomorrow is the deadline for the assignment, this is probably the last time I will write. I found out that I need to set the feet of the microcontroller to digital (which is logical of course), but unfortunately MPLAB doesn't recognize ANSEL, ANSELH or ADCON command words for some reason. Luckily I have the device with me, so if you have any ideas I can try it. Attached is the current state of the program. Also, the delay function is not correct, but i don't know how to add Nop(); or __delay_ms() from lib-pic30.h (mplab doesn't recognise it).

Re: g16f874 project

PostPosted: Fri Dec 09, 2022 3:09 am
by ric
umogi_lvr wrote: I found out that I need to set the feet of the microcontroller to digital (which is logical of course), but unfortunately MPLAB doesn't recognize ANSEL, ANSELH or ADCON command words for some reason.

The only analog pins on a PIC16F874A are in PORTA and PORTE.
The ports you are using (PORTB and PORTD) are digital only.
If you had been using PORTA, you have to write to ADCON1 to set the pins to digital mode. That is documented under "EXAMPLE 4-1: INITIALIZING PORTA" in the PIC16F874A datasheet.

Also, the delay function is not correct, but i don't know how to add Nop(); or __delay_ms() from lib-pic30.h (mplab doesn't recognise it).

lib-pic30.h is for a different compiler altogether, not XC8.
The XC8 User Guide tells you how to implement delays.
In short, it won't work with this code because you have commented out the #define for _XTAL_FREQ
That #define must be present for the _delay_ms() and __delay_us() macros to work.

Re: PIC16f874 project

PostPosted: Fri Dec 09, 2022 3:12 am
by AussieSusan
Look at the data sheet for YOUR MCU - the registers are ADCON0 and ADCON1.
Also the code that you have commented out at the start of your program file must be executed within the 'main' function (or something that it calls. These statements are NOT global defines or assignments - they are executable statements. This si basic "C" programming.
Also get rid of the 'pic16f874.h' include - the 'xc.h' include will do that for you and might stop an old file from generating sporous errors.
Don't write your own 'delay' function - any decent compiler will see that the 'for' loop you have written does nothing and will remove all the code, leaving you with no delay at all. The compiler provides delay functions/macros.
Susan

Re: PIC16f874 project

PostPosted: Wed Dec 14, 2022 2:09 am
by dan1138
Crystalfontz make a similar but different pinout LCD module:

CFAG12864B-TMI-V
https://www.crystalfontz.com/products/d ... -06-23.pdf

The Crystalfontz web site may have some useful resources,