Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
LinkBack Thread Tools Display Modes
Old 16th October 2007, 03:55 PM   (permalink)
Default PIC16F88, PIC simulator lcd trouble

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.
superbrew is offline  
Old 16th October 2007, 05:37 PM   (permalink)
Default

have you specified 16f88 in compiler before you compile and oshonsoft sim. before you load the subsequent hex file?
monkeybiter is offline  
Old 16th October 2007, 05:39 PM   (permalink)
Default

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.
__________________
Superman returns..
bananasiong is offline  
Old 16th October 2007, 05:52 PM   (permalink)
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.
superbrew is offline  
Old 16th October 2007, 06:11 PM   (permalink)
Default

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.
__________________
Superman returns..
bananasiong is offline  
Old 16th October 2007, 09:22 PM   (permalink)
Default

Quote:
Originally Posted by superbrew
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.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline  
Old 16th October 2007, 09:26 PM   (permalink)
Default

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 is offline  
Old 16th October 2007, 09:29 PM   (permalink)
Default

Quote:
Originally Posted by superbrew
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?.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline  
Old 17th October 2007, 01:39 AM   (permalink)
Default

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.
__________________
Superman returns..
bananasiong is offline  
Old 17th October 2007, 01:46 AM   (permalink)
Default

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.
Pommie is offline  
Old 17th October 2007, 03:03 AM   (permalink)
Default

Thank you all for your replies and patience. Adding ANSEL = 0x00; to my code worked. Looks like I have a lot of reading ahead.
superbrew is offline  
Old 17th October 2007, 03:18 AM   (permalink)
Default

Don't worry about it too much, everyone, and I do mean everyone, gets caught out by the analogue inputs being the default.

Mike.
Pommie is offline  
Reply

Bookmarks

Thread Tools
Display Modes



Similar Threads
Title Starter Forum Replies Latest
High ADC sampling rate PIC, 18F needed? bananasiong Micro Controllers 24 28th October 2007 01:13 PM
Greetings. A pic controlled traffic light circuit... Wiley Electronic Projects Design/Ideas/Reviews 2 13th October 2007 05:46 PM
Battery Tester with a PIC 16F818 Cicuit Question dmarciano Micro Controllers 1 9th October 2007 05:41 AM
Battery Tester with a PIC 16F818 Cicuit Question dmarciano Micro Controllers 1 9th October 2007 04:55 AM
Four PIC with One LCD.. meera83 Micro Controllers 13 20th September 2007 07:40 AM



All times are GMT. The time now is 07:03 PM.


Electronic Circuits  |  Learning Electronics
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.

eXTReMe Tracker