1. 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.
    Dismiss Notice

PIC doesn't run with internal oscillator

Discussion in 'Oshonsoft' started by camerart, Apr 13, 2014.

  1. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,396
    Likes:
    11
    Location:
    Dorset UK.
    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.
     

    Attached Files:

  2. jjw

    jjw Member

    Joined:
    Apr 16, 2012
    Messages:
    270
    Likes:
    15
    Location:
    Helsinki, Finland
    ONLINE
    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.
     
  3. skimask87

    skimask87 Member

    Joined:
    Mar 23, 2014
    Messages:
    128
    Likes:
    10
    Location:
    Logan (Minot), ND
    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.
     
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. jjw

    jjw Member

    Joined:
    Apr 16, 2012
    Messages:
    270
    Likes:
    15
    Location:
    Helsinki, Finland
    ONLINE

    But he is simulating different circuit with 8bit Lcd data. The physical circuit has 4bit Lcd data interface and might have other issues.
     
  6. misterT

    misterT Well-Known Member Most Helpful Member

    Joined:
    Apr 19, 2010
    Messages:
    2,697
    Likes:
    368
    Location:
    Finland
    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: Apr 16, 2014
  7. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,396
    Likes:
    11
    Location:
    Dorset UK.
     
  8. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,396
    Likes:
    11
    Location:
    Dorset UK.
    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?
     
  9. skimask87

    skimask87 Member

    Joined:
    Mar 23, 2014
    Messages:
    128
    Likes:
    10
    Location:
    Logan (Minot), ND
    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...'
     
    • Agree Agree x 1
  10. misterT

    misterT Well-Known Member Most Helpful Member

    Joined:
    Apr 19, 2010
    Messages:
    2,697
    Likes:
    368
    Location:
    Finland
    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.
     
  11. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,396
    Likes:
    11
    Location:
    Dorset UK.
    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
     
  12. skimask87

    skimask87 Member

    Joined:
    Mar 23, 2014
    Messages:
    128
    Likes:
    10
    Location:
    Logan (Minot), ND
    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:
     
  13. misterT

    misterT Well-Known Member Most Helpful Member

    Joined:
    Apr 19, 2010
    Messages:
    2,697
    Likes:
    368
    Location:
    Finland
    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.
     
  14. misterT

    misterT Well-Known Member Most Helpful Member

    Joined:
    Apr 19, 2010
    Messages:
    2,697
    Likes:
    368
    Location:
    Finland
    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.
     
  15. skimask87

    skimask87 Member

    Joined:
    Mar 23, 2014
    Messages:
    128
    Likes:
    10
    Location:
    Logan (Minot), ND
    We just got 2 inches of fresh snow waiting to be formed into high-speed spherical objects for just those kinds of people :D
     
  16. misterT

    misterT Well-Known Member Most Helpful Member

    Joined:
    Apr 19, 2010
    Messages:
    2,697
    Likes:
    368
    Location:
    Finland
    Watch the sarcasm there.. we use the chat here to talk behind peoples back.
     
  17. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,396
    Likes:
    11
    Location:
    Dorset UK.
    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.
     
  18. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,396
    Likes:
    11
    Location:
    Dorset UK.
    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.
     
  19. jjw

    jjw Member

    Joined:
    Apr 16, 2012
    Messages:
    270
    Likes:
    15
    Location:
    Helsinki, Finland
    ONLINE
    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: Apr 16, 2014
  20. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,396
    Likes:
    11
    Location:
    Dorset UK.
    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
     
  21. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,396
    Likes:
    11
    Location:
    Dorset UK.
    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?
     

Share This Page