Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

ks0108b/ks0107 controller combo

Status
Not open for further replies.
desaila said:
I'm seeing ADCON1 = 0x07 to configure portA for digital inputs, but there's nothing under the PORTB configuration with regards to digital or analog inputs.

However, it says on a power on reset "these ports are configured as digital inputs." Then, I guess I see that there are no AD's associated with PORTB in the final summary of regs at the bottom of PORTB's section. So, ADCON1 = 0x07 then.
Sounds right. I'm on my "accounting" computer, so I don't have access to datasheets right now. Must get some invoices out so I can eat next month.

EDIT: Just looked. What you want is on page 182 of the datasheet. 0x06 will work, but so will 0x07 as the 0-bit is a don't-care in this case.
 
Last edited:
futz said:
Well, right off the bat I have to say this #pragma
Code:
#pragma DATA _CONFIG, _CP_OFF & _PWRTE_OFF & _WDT_OFF & _HS_OSC & _LVP_OFF
is almost certainly wrong for an 18F. 18Fs have seven config words, whereas the 16Fs I wrote for only have one. Your compiler MUST have been at least warning you. It should have given you major errors.

Here's a set of typical BoostC pragmas for an 18F452
Code:
#pragma DATA    _CONFIG1H, _OSCS_OFF_1H & _HS_OSC_1H
#pragma DATA    _CONFIG2L, _BOR_ON_2L & _BORV_20_2L & _PWRT_OFF_2L
#pragma DATA    _CONFIG2H, _WDT_OFF_2H & _WDTPS_128_2H
#pragma DATA    _CONFIG3H, _CCP2MX_ON_3H
#pragma DATA    _CONFIG4L, _STVR_ON_4L & _LVP_OFF_4L & _DEBUG_OFF_4L
#pragma DATA    _CONFIG5L, _CP0_OFF_5L & _CP1_OFF_5L & _CP2_OFF_5L & _CP3_OFF_5L
#pragma DATA    _CONFIG5H, _CPB_OFF_5H & _CPD_OFF_5H
#pragma DATA    _CONFIG6L, _WRT0_OFF_6L & _WRT1_OFF_6L & _WRT2_OFF_6L & _WRT3_OFF_6L
#pragma DATA    _CONFIG6H, _WRTC_OFF_6H & _WRTB_OFF_6H & _WRTD_OFF_6H
#pragma DATA    _CONFIG7L, _EBTR0_OFF_7L & _EBTR1_OFF_7L & _EBTR2_OFF_7L & _EBTR3_OFF_7L
#pragma DATA    _CONFIG7H, _EBTRB_OFF_7H

And here's a minimum one that I use mostly:
Code:
#pragma	CLOCK_FREQ	32000000
#pragma DATA    _CONFIG1H, _OSC_INTIO67_1H
#pragma DATA    _CONFIG2H, _WDT_OFF_2H
#pragma DATA    _CONFIG3H, _MCLRE_ON_3H
#pragma DATA    _CONFIG4L, _LVP_OFF_4L & _XINST_OFF_4L
That CLOCK_FREQ line is so the delay lib calculates delays correctly.

All the above assumes BoostC. Your compiler may have different syntax.

I changed my inputs to the Latching system as recommended, threw in ADCON1 = 0x07 immediately after variable declaration, and tried looking up these various pragmas in the MPLAB C18 user guides I have in this lab, and couldn't find any of the ones you used, or their explanations. I tried searching through the data sheet as well. Where can I find configuration info? I tried google'ing a few of them, but nothing terribly useful came up, not that I could see anyway.

(no change in status of lcd).
 
desaila said:
and tried looking up these various pragmas in the MPLAB C18 user guides I have in this lab, and couldn't find any of the ones you used, or their explanations.
Ok, you can't use the same pragmas as BoostC. C18 has a sort of simplified version of the same thing though.

I tried searching through the data sheet as well.
The datasheet has good info on the configs, but not compiler specific info.

Where can I find configuration info?
Relax. Here it comes. :D

In your MCC18 dir you'll find an mpasm dir. In there you'll find a file called P18F452.INC. Near the bottom of that you'll find this list:
Code:
;   Oscillator Selection:
;     OSC = LP             LP
;     OSC = XT             XT
;     OSC = HS             HS
;     OSC = RC             RC
;     OSC = EC             EC-OSC2 as Clock Out
;     OSC = ECIO           EC-OSC2 as RA6
;     OSC = HSPLL          HS-PLL Enabled
;     OSC = RCIO           RC-OSC2 as RA6
;
;   Osc. Switch Enable:
;     OSCS = ON            Enabled
;     OSCS = OFF           Disabled
;
;   Power-up Timer:
;     PWRT = ON            Enabled
;     PWRT = OFF           Disabled
;
;   Brown-out Reset:
;     BOR = OFF            Disabled
;     BOR = ON             Enabled
;
;   Brown-out Voltage:
;     BORV = 45            4.5V
;     BORV = 42            4.2V
;     BORV = 27            2.7V
;     BORV = 25            2.5V
;
;   Watchdog Timer:
;     WDT = OFF            Disabled
;     WDT = ON             Enabled
;
;   Watchdog Postscaler:
;     WDTPS = 1            1:1
;     WDTPS = 2            1:2
;     WDTPS = 4            1:4
;     WDTPS = 8            1:8
;     WDTPS = 16           1:16
;     WDTPS = 32           1:32
;     WDTPS = 64           1:64
;     WDTPS = 128          1:128
;
;   CCP2 MUX:
;     CCP2MUX = OFF        Disable (RB3)
;     CCP2MUX = ON         Enable (RC1)
;
;   Stack Overflow Reset:
;     STVR = OFF           Disabled
;     STVR = ON            Enabled
;
;   Low Voltage ICSP:
;     LVP = OFF            Disabled
;     LVP = ON             Enabled
;
;   Background Debugger Enable:
;     DEBUG = ON           Enabled
;     DEBUG = OFF          Disabled
;
;   Code Protection Block 0:
;     CP0 = ON             Enabled
;     CP0 = OFF            Disabled
;
;   Code Protection Block 1:
;     CP1 = ON             Enabled
;     CP1 = OFF            Disabled
;
;   Code Protection Block 2:
;     CP2 = ON             Enabled
;     CP2 = OFF            Disabled
;
;   Code Protection Block 3:
;     CP3 = ON             Enabled
;     CP3 = OFF            Disabled
;
;   Boot Block Code Protection:
;     CPB = ON             Enabled
;     CPB = OFF            Disabled
;
;   Data EEPROM Code Protection:
;     CPD = ON             Enabled
;     CPD = OFF            Disabled
;
;   Write Protection Block 0:
;     WRT0 = ON            Enabled
;     WRT0 = OFF           Disabled
;
;   Write Protection Block 1:
;     WRT1 = ON            Enabled
;     WRT1 = OFF           Disabled
;
;   Write Protection Block 2:
;     WRT2 = ON            Enabled
;     WRT2 = OFF           Disabled
;
;   Write Protection Block 3:
;     WRT3 = ON            Enabled
;     WRT3 = OFF           Disabled
;
;   Boot Block Write Protection:
;     WRTB = ON            Enabled
;     WRTB = OFF           Disabled
;
;   Configuration Register Write Protection:
;     WRTC = ON            Enabled
;     WRTC = OFF           Disabled
;
;   Data EEPROM Write Protection:
;     WRTD = ON            Enabled
;     WRTD = OFF           Disabled
;
;   Table Read Protection Block 0:
;     EBTR0 = ON           Enabled
;     EBTR0 = OFF          Disabled
;
;   Table Read Protection Block 1:
;     EBTR1 = ON           Enabled
;     EBTR1 = OFF          Disabled
;
;   Table Read Protection Block 2:
;     EBTR2 = ON           Enabled
;     EBTR2 = OFF          Disabled
;
;   Table Read Protection Block 3:
;     EBTR3 = ON           Enabled
;     EBTR3 = OFF          Disabled
;
;   Boot Block Table Read Protection:
;     EBTRB = ON           Enabled
;     EBTRB = OFF          Disabled
Take the ones you need and put them after #pragma config. This small set of pragma's should get you going. You'll have to change the OSC line to suit your oscillator. I assumed you'd be using a HS (high speed) crystal. Change that to suit how you're doing it. To find which one to use, refer to Page 17 in the datasheet:
Code:
#pragma config OSC = HS
#pragma config WDT = OFF
#pragma config LVP = OFF

EDIT: I downloaded C18 and tested a bit. On my 18F4620, using internal oscillator, I'm using this #pragma for a simple blinky program:
Code:
#include <p18cxxx.h>
#include <delays.h>

#pragma config OSC = INTIO67, WDT = OFF, LVP = OFF

void main(void)
{
	TRISD = 0;
	while(1){
		LATDbits.LATD1 = 1;
		Delay100TCYx(100);
		LATDbits.LATD1 = 0;
		Delay100TCYx(100);
	}
}
As you can see, you can put them all on one line with commas between them if you prefer it over one-per-line.
 
Last edited:
Thanks a bunch! I'm not going to be in the lab again tonight, but I'm going to head over there first thing in the morning to give this a go.
 
heh, so I just changed some of the init things to test out, and i was playing with the contrast potentiometer i have setup, and the thing started smoking...(not the pot, but the lcd itself.) I cut the power as quick as I could and turned it over to investigate and nothing looks damaged.

so now i'm petrified that it burnt out. Is there a way to verify that the lcd might actually be working despite nothing showing up on it?

EDIT: Also, in case the thing is still working... I'm using a 20 mhz oscillator, so should I be using a Delay1KTCYx() instead of the Nops?

Or do you have like simplified code that just puts out like 1 letter to the device or something, so I can just try adn get the timing down on this thing and verify if it's really dead or not? (sorta like your blinky program)?
 
Last edited:
Smoke = bad. LCD displays are very sensitive to incorrectly applied power and such. I've killed a couple in my day from just a brief power reversal.
 
blueroomelectronics said:
Smoke = bad. LCD displays are very sensitive to incorrectly applied power and such. I've killed a couple in my day from just a brief power reversal.


Aye, tbh I think it has something to do wtih the company. The first LCD I got from them smoked the first time I wired it up. I called them, told them what happened and that I tested all the voltages prior to wiring it up, and after the failure and they wre all within operating range.

They sent me a new one for free, the second one they sent me is the one I have now. I had my professor help me wire it, test all the voltages before we wired it up, etc. So I really don't think it's my fault, maybe it was =/
 
desaila said:
so now i'm petrified that it burnt out. Is there a way to verify that the lcd might actually be working despite nothing showing up on it?
You let the magic smoke out. :D Pretty unlikely that it still works, but try it anyway. You can't hurt it anymore than you already have. If you've smoked two in a row it's your faulty wiring, not the display, that's at fault.

I had my professor help me wire it, test all the voltages before we wired it up, etc.
Perhaps your professor has misunderstood something on the datasheet, or made a mistake. Have a look at my schematic and confirm your wiring again.

EDIT: Also, in case the thing is still working... I'm using a 20 mhz oscillator, so should I be using a Delay1KTCYx() instead of the Nops?
No. The nops are fine. It's happy at 20MHz with that code.

Or do you have like simplified code that just puts out like 1 letter to the device or something, so I can just try adn get the timing down on this thing and verify if it's really dead or not? (sorta like your blinky program)?
That's as simple as it gets. This isn't a text LCD. Any text it puts on screen gets put there the hard way, by your code. Make your own font and find a way to display it as a bitmap.
 
Last edited:
I understand the nature of this lcd not being text driven and having to get your own character libraries, etc

Also, I have it wired in a very similar way. Just a potentiometer instead of a 10k. It wasn't just my professor either, I had the TA double check it prior to firing it up for the first time. It was fine for ~2 weeks and them smoked. Is that something that can be expected?
 
desaila said:
Also, I have it wired in a very similar way. Just a potentiometer instead of a 10k. It wasn't just my professor either, I had the TA double check it prior to firing it up for the first time. It was fine for ~2 weeks and them smoked.
Drifting power wires? Power supply problem? Better start looking for a cause, cuz that smoke thing isn't good. :p

Is that something that can be expected?
NO!
 
haha, i was sort of being sarcastic when i asked if that was to be expected. and i had the data sheet from the company. that's what i based my wiring scheme on.
 
I use the same type display 128x64 on my Unicorn. Check its schematic (free to download) in the Unicorn assembly manual on my site. That type of display generates it own negative contrast voltage.
**broken link removed**
 
It may help you.
 

Attachments

  • pic_glcd.zip
    143.5 KB · Views: 181
erie said:
It may help you.
absolutely. thank you.

EDIT: I got off the phone with the company, they're sending me a new one, and I wont be able to resume work until Monday (when it arrives).
 
Last edited:
Futz, I'm looking at your schematic and it seems that you have Vo and Vee connected to a 10k resistor and then to Vdd(+5) ?

link to schematic: **broken link removed**
 
desaila said:
Futz, I'm looking at your schematic and it seems that you have Vo and Vee connected to a 10k resistor and then to Vdd(+5) ?
That's not a resistor. It's a 10K potentiometer with wiper to VO. I know, technically a pot IS a resistor, but you know what I mean.

I pretty much copied **broken link removed** schematic.
 
Last edited:
futz said:
That's not a resistor. It's a 10K potentiometer with wiper to VO. I know, technically a pot IS a resistor, but you know what I mean.

I pretty much copied **broken link removed** schematic.

what does wiper to VO mean?
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top