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.

PIC doesn't run with internal oscillator

Status
Not open for further replies.
Hi, [16F648A with XTL and LCD 4X20 module.]

Can we start again from here, in case I've complicated things?

I have attached a photo, of the latest wiring, the Oshonsoft program and the code.

This program works ok in the Oshonsoft simulator, but not in the circuit. If I comment out the LCD part of the program except the 'TOGGLE RA1' which is an indicator LED, then the led flashes in the circuit.

Camerart.
 

Attachments

  • PICLCD.jpg
    PICLCD.jpg
    297 KB · Views: 377
  • PICLCD.txt
    564 bytes · Views: 371
  • PIC LCD.txt
    3.3 KB · Views: 491
I don't think anyone wan'ts to see the hex file.
I meant that you should post the code inside your message, not as an attachment.
The code is not correct with your schematic, 8bit lcd data vs. 4bit etc.
Long wires may give problems.
 
Hi, [16F648A with XTL and LCD 4X20 module.]
This program works ok in the Oshonsoft simulator, but not in the circuit.
Camerart.
If that's actually the case, then that simulator is complete garbage. There is no way, exactly zero percent chance, that circuit that you've shown us, can make the LCD work in the simulated circuit AND the physical circuit with the same code.
And don't ground D0-D3 on the LCD. Doesn't need it. And if you are going to ground, I surely wouldn't put them directly to ground on the same wire. Bad practice. Always use a pull down resistor in line with signals that are being pulled up or pulled down.
 
But he is simulating different circuit with 8bit Lcd data. The physical circuit has 4bit Lcd data interface and might have other issues.
 
I kind of thought that beginners need advice on programming. Now I think that beginners need advice on simple debugging. Well, same thing, but every tutorial forgets the debugging part.

Step Zero:
Never trust a simulator.
You can simulate things, but first you need to know the component you are simulating.
You can't learn the component by simulating.

Step one:
Write a simple program that blinks a LED..
If that works, check that the timing is ok. Make the LED blink at 1 Hz interval and time it..
If that works.. you can be almost sure that the chip is ok and CPU frequency is (probably) correct.. Sometimes when the chip just resets itself it can look like everything is ok.
 
Last edited:
I don't think anyone wan'ts to see the hex file.
I meant that you should post the code inside your message, not as an attachment.
The code is not correct with your schematic, 8bit lcd data vs. 4bit etc.
Long wires may give problems.

I kind of thought that beginners need advice on programming. Now I think that beginners need advice on simple debugging. Well, same thing, but every tutorial forgets the debugging part.

Step Zero:
Never trust a simulator.
You can simulate things, but first you need to know the component you are simulating.
You can't learn the component by simulating.

Step one:
Write a simple program that blinks a LED..
If that works, check that the timing is ok. Make the LED blink at 1 Hz interval and time it..
If that works.. you can be almost sure that the chip is ok and CPU frequency is (probably) correct.. Sometimes when the chip just resets itself it can look like everything is ok.
 
There is an indicator LED in the loop 'TOGGLE RA1' as I said before, and that does work at 1second if the code dictates.

Are there any suggestions for a tried and tested schematic, and program that I can follow?
 
Forget the simulator...Forget the simulator...Forget the simulator.

Post the code you are trying to get to run on your hardware.

Post a schematic of the hardware you are using.

Post a good picture of the hardware you have wired up and are running the code on.

You've got 3 things going on at once. 2 of those 3 things don't match up. Once you see what we see (or maybe I see, I don't know), it will work, but only if you 'Forget the simulator...'
 
Are there any suggestions for a tried and tested schematic, and program that I can follow?

You can follow your own program to find the problem.. that is the idea of a "blinking LED". You add things to your code in small pieces and once the "LED" stops blinking you have found your problem.

And the "LED" here can be anything.. the main idea is to start from scratch and keep adding features until the code does not work.. You need to be a little smart to figure out what is the indicator that the code works.
 
Forget the simulator...Forget the simulator...Forget the simulator.

Post the code you are trying to get to run on your hardware.

Post a schematic of the hardware you are using.

Post a good picture of the hardware you have wired up and are running the code on.

You've got 3 things going on at once. 2 of those 3 things don't match up. Once you see what we see (or maybe I see, I don't know), it will work, but only if you 'Forget the simulator...'

Is the photo I posted in #21 no good? I don't have a proper schematic, I'm only following ideas from Google like the one I posted. I've changed the wires round to clear pins 15 and 16 for a XTL.

Program in Oshinsoft basic (All I know)
'16f684A xtl

Define CONF_WORD = 0x3f41 'XTL
Define CLOCK_FREQUENCY = 4 'Changed from 12
AllDigital

'Define SIMULATION_WAITMS_VALUE = 1 'SIMULATION ONLY

Define LCD_BITS = 8
Define LCD_DREG = PORTB
Define LCD_DBIT = 0
Define LCD_RSREG = PORTA
Define LCD_RSBIT = 2
Define LCD_RWREG = PORTA
Define LCD_RWBIT = 3
Define LCD_EREG = PORTA
Define LCD_EBIT = 4
Define LCD_READ_BUSY_FLAG = 1
Lcdinit

'Dim an0 As Word

loop:
Lcdcmdout LcdClear
Lcdout "WORKING!?"
Lcdcmdout LcdLine2Home
Lcdout "TEST"
Toggle RA1
WaitMs 100
Goto loop
 
Ok, now look very VERY VERY hard at your wiring...

Now look very VERY VERY closely at the first dozen or so lines of your code...

:rolleyes: I see you paid a lot of attention to my previous post#23... :rolleyes:
 
Is the photo I posted in #21 no good?

Yes, almost no good. And even when you post schematics there is no way we can be sure that your actual circuit is what you posted.. that is the problem when communicating through forums with people around the world. The more info you post and the more accurate and careful you are with the info you post, the better help you get.
 
I've been involved in several threads. Many pages long.. and the final result was: "oh, problems solved.. one of my components was not properly soldered"

So, check that you are posting correct info. One wrong info from you and the thread takes 180 degrees turn to wrong direction.. we can only guess. You can check, measure and debug.
 
I've been involved in several threads. Many pages long.. and the final result was: "oh, problems solved.. one of my components was not properly soldered"
We just got 2 inches of fresh snow waiting to be formed into high-speed spherical objects for just those kinds of people :D
 
We just got 2 inches of fresh snow waiting to be formed into high-speed spherical objects for just those kinds of people :D

Watch the sarcasm there.. we use the chat here to talk behind peoples back.
 
Ok, now look very VERY VERY hard at your wiring...

Now look very VERY VERY closely at the first dozen or so lines of your code...

:rolleyes: I see you paid a lot of attention to my previous post#23... :rolleyes:
Ok, now look very VERY VERY hard at your wiring...

Now look very VERY VERY closely at the first dozen or so lines of your code...

:rolleyes: I see you paid a lot of attention to my previous post#23... :rolleyes:

I did take the GND off, just didn't post a fresh photo, unless you want to see:)

Now I've looked a the code and my wiring, and call it dylexiar, but I can't see what you mean.
 
I've been involved in several threads. Many pages long.. and the final result was: "oh, problems solved.. one of my components was not properly soldered"

So, check that you are posting correct info. One wrong info from you and the thread takes 180 degrees turn to wrong direction.. we can only guess. You can check, measure and debug.

I do try to be as careful as possible when posting, but I generally post after a day of failure, when I'm well past being tired, sorry.
 
You don't listen.
There are at least four messages which tell you to look at your circuit and look at your program.
Are there some conflicts between your code and your circuit ?
If you copy code from Oshonsoft Basic manual, you should understand what it is doing.
 
Last edited:
You don't listen.
There are at least four messages which tell you to look at your circuit and look at your program.
Are there some conflicts between your code and your circuit ?
If you copy code from Oshonsoft Basic manual, you should understand what it is doing.

Ok, leave it with me, It get's more difficult as I get older, and I can see it causing frustration.

I'll let you know if I get it going.

Thanks to all for trying.
Cheers, Camerart
 
Really?
You don't see the one (or four) things that are keeping everything from working?
That one (or four) things that is right near the beginning of your code?
The 0, 1, 2, or 3 things...
That little nybble of information is just half of a byte of what you can't find?
4 little bits of information that are right in front of you?

This reminds me of when I was 7 years old, and being kept in after school by the math/s teacher. It didn't help, I'm still not good at it, and I remember that day well.

Anyway! I changed these:
Define LCD_BITS = 4
Define LCD_DREG = PORTB
Define LCD_DBIT = 4

But it didn't work. (I tried it days ago) Is this somewhere near to what you are hinting?
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top