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.

PIC16F88, PIC simulator lcd trouble

Status
Not open for further replies.

superbrew

Member
Hello, I am new to microcontrollers. I am using MikroC and the OshonSoftware simulator. I am trying to display some text on the LCD module of the simulator. I am able to get to work if I complile my code using a 16F877, but it does not work if I compile as a 16F88. This is what I am using as code:

void main(){
TRISB = 0x00;

LCD_INIT(&PORTB);
LCD_CMD(LCD_CLEAR);
LCD_OUT(1,1,"A");
}

I have the LCD display set using 2 x 16, PORTB as data, interface 4-bit high, RS line PORTB 2, E line PORTB 3, RW not used.

I would like to get it to work with 16F88, as that is what I have on hand. Thank you.
 
have you specified 16f88 in compiler before you compile and oshonsoft sim. before you load the subsequent hex file?
 
Hi,
Have you disabled analogue input? RB6 and RB7 are also used as analogue input pins, AN5 and AN6. They are set as analog in default.
 
monkeybiter, yes, I set the compiler to 16F88. The simulator gives an error if I don't. I have made the leds blink using the 16F88 with this simulator.

bananasiong, I thought the 'TRISB = 0x00;' sets PORTB as output.

Thanks for the quick replies.
 
Hi,
You don't you give a try to disable the analog input?
I've simulated using MPLAB, I think the priority is given to the analog select register.
After occurance of any reset, ANSEL will all be set.
 
superbrew said:
monkeybiter, yes, I set the compiler to 16F88. The simulator gives an error if I don't. I have made the leds blink using the 16F88 with this simulator.

bananasiong, I thought the 'TRISB = 0x00;' sets PORTB as output.

It doesn't cancel the analogue inputs, you need to do that as well.
 
Forgive my ignorance, but how do I do that? I did manage to get it to display some characters, although not what I wanted. I copied the code from the MikroC user's manual.
 
superbrew said:
Forgive my ignorance, but how do I do that? I did manage to get it to display some characters, although not what I wanted. I copied the code from the MikroC user's manual.

Check your C manual, sorry I don't do C - it's trivial in assembler though, presumably it won't be any harder in C?.
 
Hi,
Read the datasheet under analog to digital conversion. There is a register called ANSEL that allow you to select from AN0 to AN6 whether is digital I/O or analog I/O. 0 for digital and 1 for analog, the default is 1. If you're not using any analog input, simply clear them. Just like setting the port direction, TRISB.
 
Try,

ANSEL = 0x00;

Analogue inputs still work as digital outputs but always read back as 0. This is fine for a lot of things but when you just setting bits it can cause problems. You would also get problems reading the status of the LCD which explains your corrupted characters.

Mike.
 
Thank you all for your replies and patience. Adding ANSEL = 0x00; to my code worked. Looks like I have a lot of reading ahead.
 
Don't worry about it too much, everyone, and I do mean everyone, gets caught out by the analogue inputs being the default.

Mike.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top