PIC16f874 project

(instructions, reset, WDT, specifications...) PIC12F6xx, PIC16Fxxx, PIC16F6x, PIC16F7x

Re: PIC16f874 project

Postby umogi_lvr » Tue Dec 06, 2022 12:54 pm

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.
Attachments
dat.PNG
dat.PNG (64.03 KiB) Viewed 2654 times
bme_lcd_komp.txt
(6.34 KiB) Downloaded 104 times
code.c
(1.14 KiB) Downloaded 103 times
umogi_lvr
 
Posts: 8
Joined: Thu Dec 01, 2022 3:51 pm

Re: PIC16f874 project

Postby umogi_lvr » Tue Dec 06, 2022 2:23 pm

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).
Attachments
pic16f877.c
(4.43 KiB) Downloaded 97 times
pic.PNG
pic.PNG (126.57 KiB) Viewed 2654 times
pins.PNG
pins.PNG (41.75 KiB) Viewed 2654 times
umogi_lvr
 
Posts: 8
Joined: Thu Dec 01, 2022 3:51 pm

Re: PIC16f874 project

Postby ric » Wed Dec 07, 2022 5:22 am

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.
Latest test project, an LED matrix display made from one reel of addressable LEDs. here
User avatar
ric
Verified identity
 
Posts: 659
Joined: Sat May 24, 2014 2:35 pm
Location: Melbourne, Australia
PIC experience: Professional 5+ years with MCHP products

Re: PIC16f874 project

Postby ric » Wed Dec 07, 2022 5:27 am

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.
Latest test project, an LED matrix display made from one reel of addressable LEDs. here
User avatar
ric
Verified identity
 
Posts: 659
Joined: Sat May 24, 2014 2:35 pm
Location: Melbourne, Australia
PIC experience: Professional 5+ years with MCHP products

Re: PIC16f874 project

Postby AussieSusan » Wed Dec 07, 2022 5:50 am

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
AussieSusan
Verified identity
 
Posts: 173
Joined: Mon Jun 16, 2014 4:45 am
PIC experience: Experienced Hobbyist

Re: PIC16f874 project

Postby ric » Wed Dec 07, 2022 5:58 am

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.
Latest test project, an LED matrix display made from one reel of addressable LEDs. here
User avatar
ric
Verified identity
 
Posts: 659
Joined: Sat May 24, 2014 2:35 pm
Location: Melbourne, Australia
PIC experience: Professional 5+ years with MCHP products

Re: g16f874 project

Postby umogi_lvr » Thu Dec 08, 2022 5:12 pm

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).
Attachments
newmain.c
(10.23 KiB) Downloaded 104 times
umogi_lvr
 
Posts: 8
Joined: Thu Dec 01, 2022 3:51 pm

Re: g16f874 project

Postby ric » Fri Dec 09, 2022 3:09 am

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.
Latest test project, an LED matrix display made from one reel of addressable LEDs. here
User avatar
ric
Verified identity
 
Posts: 659
Joined: Sat May 24, 2014 2:35 pm
Location: Melbourne, Australia
PIC experience: Professional 5+ years with MCHP products

Re: PIC16f874 project

Postby AussieSusan » Fri Dec 09, 2022 3:12 am

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
AussieSusan
Verified identity
 
Posts: 173
Joined: Mon Jun 16, 2014 4:45 am
PIC experience: Experienced Hobbyist

Re: PIC16f874 project

Postby dan1138 » Wed Dec 14, 2022 2:09 am

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,
dan1138
 
Posts: 9
Joined: Sat May 30, 2015 6:59 pm
PIC experience: Professional 5+ years with MCHP products

Previous

Return to 14-Bit Core

Who is online

Users browsing this forum: No registered users and 11 guests

cron