Biggest weird problem

Page: 12 > Showing page 1 of 2
Author
cedric13
Starting Member
  • Total Posts : 33
  • Reward points : 0
  • Joined: 2014/04/17 06:15:43
  • Location: France,Marseille
  • Status: offline
2014/06/12 02:20:43 (permalink)
0

Biggest weird problem

Since i had a lot of problem with my lastest pic (18f87j11) i just changed it for a 18f87k22(with EEPROM and RTCC include).
 
I start my program, i had the previous IN.
I re-start my program, i had my program.
I need to program twice all the time for having it.
Someone knows how to fix it?
Thanks you.
#1

28 Replies Related Threads

    ric
    Super Member
    • Total Posts : 22101
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: offline
    Re: Biggest weird problem 2014/06/12 04:57:34 (permalink)
    4 (1)
    Why is this question in the "Serial EEPROMS - I2C" forum?
    What IDE and programmer are you using?
    How do you know you have the previous version of your program?
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #2
    cedric13
    Starting Member
    • Total Posts : 33
    • Reward points : 0
    • Joined: 2014/04/17 06:15:43
    • Location: France,Marseille
    • Status: offline
    Re: Biggest weird problem 2014/06/12 05:32:19 (permalink)
    0
    I don't know where i can post this kind of topic.
    MPLAB X IDE v2.05
    I have an LCD, i'm typing something like "Ahah".
    I program, nothing happens. I program again, "Ahah" appears.
    I change my program to "Oh". I program, "Ahah" appears.
    I program again "Oh" appears. Etc etc.
    #3
    NKurzman
    A Guy on the Net
    • Total Posts : 16572
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: offline
    Re: Biggest weird problem 2014/06/12 06:27:01 (permalink)
    0
    in this context "program" is your code.
    So your PIC works, but you are having trouble writing to an LCD Module?
    #4
    cedric13
    Starting Member
    • Total Posts : 33
    • Reward points : 0
    • Joined: 2014/04/17 06:15:43
    • Location: France,Marseille
    • Status: offline
    Re: Biggest weird problem 2014/06/12 06:49:11 (permalink)
    0
    Seems to work, but not as i want to.
    I need to program twice, and the LCD is writing my program.
    Maybe a bad configuration from the I2C but i'm on it since 2 days trying everything possible. Nothing seems to fix it.
    #5
    cedric13
    Starting Member
    • Total Posts : 33
    • Reward points : 0
    • Joined: 2014/04/17 06:15:43
    • Location: France,Marseille
    • Status: offline
    Re: Biggest weird problem 2014/06/15 23:28:41 (permalink)
    0
    any help? :(
    #6
    pcbbc
    Super Member
    • Total Posts : 459
    • Reward points : 0
    • Joined: 2014/03/27 07:04:41
    • Location: 0
    • Status: offline
    Re: Biggest weird problem 2014/06/16 00:30:33 (permalink)
    3 (1)
    A guess:

    Is it possible the device is held in reset after the OP programs?
    So the act of starting the next program temporarily releases reset, and the previous program runs momentarily?
    Just long enough for the old program to execute and write the old text to the LCD? Thereafter the LCD retains that text because it does not share it's reset line with the uP?

    @ the OP:
    1. What programmer are you using?
    2. What do you do after you complete programming? Disconnect the programmer? Leave it connected? Use it to debug your code?
    3. When does the text from the "old" program appear? As you start programming the new code, or immediately once it has finished?
    4. What other indications do they have (e.g. Led blinky / pin toggle) that you code is actually running? Make your program do something else observable after you complete the write to the LCD so you can be sure your code is executing.
    5. Was this project working with the 18f87k22 before you changed target?
    #7
    cedric13
    Starting Member
    • Total Posts : 33
    • Reward points : 0
    • Joined: 2014/04/17 06:15:43
    • Location: France,Marseille
    • Status: offline
    Re: Biggest weird problem 2014/06/16 04:39:54 (permalink)
    2 (1)
    @ the OP:
    1. What programmer are you using?
    --> MPLAB X IDE v2.05
    2. What do you do after you complete programming? Disconnect the programmer? Leave it connected? Use it to debug your code?
    --> LEave it connected
    3. When does the text from the "old" program appear? As you start programming the new code, or immediately once it has finished?
    --> When i start programming the new code
    4. What other indications do they have (e.g. Led blinky / pin toggle) that you code is actually running? Make your program do something else observable after you complete the write to the LCD so you can be sure your code is executing.
    --> I turn on a led(the code is executing)
    5. Was this project working with the 18f87k22 before you changed target?
    --> I was using a 18f87j11, the code was working.
     
    With the pic18f87j11, i was using a clock 32.25 kHz as main clock. And now i'm using a 8MHz clock as main.
    Do you think the problem would be the clock?
    #8
    ric
    Super Member
    • Total Posts : 22101
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: offline
    Re: Biggest weird problem 2014/06/16 04:56:34 (permalink)
    4 (2)
    cedric13
    @ the OP:
    1. What programmer are you using?
    --> MPLAB X IDE v2.05

    That is the IDE, not the programmer.
    The expected answer would be something like "PICkit3", "ICD3", "Real-ICE", "Third party programmer"...
     
    2. What do you do after you complete programming? Disconnect the programmer? Leave it connected? Use it to debug your code?
    --> LEave it connected
    3. When does the text from the "old" program appear? As you start programming the new code, or immediately once it has finished?
    --> When i start programming the new code

    I would agree with pcbbc's guess above. Your old code is briefly running when you program new code into the chip.

    4. What other indications do they have (e.g. Led blinky / pin toggle) that you code is actually running? Make your program do something else observable after you complete the write to the LCD so you can be sure your code is executing.
    --> I turn on a led(the code is executing)

    It would be better to slowly flash the LED. Otherwise you only know that your code started to run, nit that it is still running.
     
    With the pic18f87j11, i was using a clock 32.25 kHz as main clock. And now i'm using a 8MHz clock as main.
    Do you think the problem would be the clock?

    I doubt it.

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #9
    cedric13
    Starting Member
    • Total Posts : 33
    • Reward points : 0
    • Joined: 2014/04/17 06:15:43
    • Location: France,Marseille
    • Status: offline
    Re: Biggest weird problem 2014/06/16 05:03:37 (permalink)
    3 (1)
    That is the IDE, not the programmer.
    The expected answer would be something like "PICkit3", "ICD3", "Real-ICE", "Third party programmer"...
     
     
    --> PICKIT 3!
     
    #10
    pcbbc
    Super Member
    • Total Posts : 459
    • Reward points : 0
    • Joined: 2014/03/27 07:04:41
    • Location: 0
    • Status: offline
    Re: Biggest weird problem 2014/06/16 05:12:10 (permalink)
    4 (1)
    The fact that you state the text from the previous program appears "As you start to program"  (not after programming finishes) implies it is only at this point that the uP starts to execute your previously programmed code.
    I'd suggest making your LED blink, not just turn on.  Having it turn on is only an indication your code has reached a certain point, not that it is still executing.
    My guess is that for some reason, immediately after programming, the uP is not actually starting to run your newly programmed code.  It only starts running (momentarily) once you initiate the next programming cycle.
    I'd also try disconnecting the programmer and also stepping through in debug (Edit*: obviously with debugger re-connected!).
     
    You should also explain which clock source your are using (external/internal) and also how your are powering your circuit.  Ideally provide full schematics and pictures of board layouts (or what kit you are using) if you can.  If the problem is the uP being held in reset as I suspect, others may be able to point you in the correct direction as to why with these details - without them, we are all kind of guessing!
    post edited by pcbbc - 2014/06/16 05:14:10
    #11
    cedric13
    Starting Member
    • Total Posts : 33
    • Reward points : 0
    • Joined: 2014/04/17 06:15:43
    • Location: France,Marseille
    • Status: offline
    Re: Biggest weird problem 2014/06/16 23:07:47 (permalink)
    3 (2)
    I'd suggest making your LED blink, not just turn on.  Having it turn on is only an indication your code has reached a certain point, not that it is still executing.

    --> That's what i already did
    LATDbits.LATD7 = LATDbits.LATD7
    The led is blinking, but the LCD do not respond until i reprogram.

    I'm using an internal clock (8 Mhz) (i also tried with 16 MHz, 4 MHz, 1 MHz).
    I have a PIC 18 Explorer Board (and programmer pickit 3)
    h ttp://www.microchip.com/Developmenttools/ProductDetails.aspx?PartNO=DM183032
     
     
    #12
    ric
    Super Member
    • Total Posts : 22101
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: offline
    Re: Biggest weird problem 2014/06/16 23:14:40 (permalink)
    4 (1)
    Can you post your whole code as an attachment?
    I'm sure it's something simple, but too hard to diagnose by just asking questions without seeing the real code.
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #13
    cedric13
    Starting Member
    • Total Posts : 33
    • Reward points : 0
    • Joined: 2014/04/17 06:15:43
    • Location: France,Marseille
    • Status: offline
    Re: Biggest weird problem 2014/06/17 02:38:10 (permalink)
    0
    h ttp://www.partage-facile.com/8A4I43KOG9/code.rar.html
    Good luck :D
    #14
    pcbbc
    Super Member
    • Total Posts : 459
    • Reward points : 0
    • Joined: 2014/03/27 07:04:41
    • Location: 0
    • Status: offline
    Re: Biggest weird problem 2014/06/17 03:05:02 (permalink)
    0
        INTCONbits.GIE = 1;
        RCONbits.IPEN = 0;
        INTCONbits.PEIE = 1;
        PIE6bits.EEIE = 1;
        PIE1bits.TMR2IE = 1;
    So, you have enabled interrupts, but do not have an ISR defined anywhere (either that or you haven't included your full project source as asked).
     
     
    There is no code here to flash a LED at the end of your main.  Unless you put the flashing in your ISR (which you didn't supply).  If it's in your ISR it doesn't prove your mainline code is running.  All it proves is your ISR is running, and perhaps your mainline code is hung (due to incorrectly serviced ISR).
     
    But again we are guessing because this doesn't look like your complete project...
     
    And a coding tip (not that it looks like you use any of these routines anywhere):
    void lettre (char c)
    {
        SWPutcI2C((c & 0xF0) |0x0D);
        SWAckI2C();
        SWPutcI2C((c & 0xF0) | 0x09);
        SWAckI2C();
        SWPutcI2C((c << 4) | 0x0D);
        SWAckI2C();
        SWPutcI2C((c << 4) | 0x09);
        SWAckI2C();
    }
     
    lettre('A');

    #15
    cedric13
    Starting Member
    • Total Posts : 33
    • Reward points : 0
    • Joined: 2014/04/17 06:15:43
    • Location: France,Marseille
    • Status: offline
    Re: Biggest weird problem 2014/06/17 05:33:37 (permalink)
    0
    h ttp://www.partage-facile.com/4AD91CBF2J/v6_main.x.rar.html
    here is my full program, but i don't understand your code for a caractere?
     
    #16
    ric
    Super Member
    • Total Posts : 22101
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: offline
    Re: Biggest weird problem 2014/06/17 06:04:03 (permalink)
    4 (1)
    cedric13
    h ttp://www.partage-facile.com/4AD91CBF2J/v6_main.x.rar.html

    As mentioned above, you are enabling interrupts for eeprom and timer2, but you don't have an interrupt service routine anywhere. That's a recipe for an instant crash.
     

    here is my full program, but i don't understand your code for a caractere?

    Your code for writing characters is pretty inefficient, having a separate routine for every single character.
    The suggested function can display any character, you just pass the desired character into the function as the argument.

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #17
    pcbbc
    Super Member
    • Total Posts : 459
    • Reward points : 0
    • Joined: 2014/03/27 07:04:41
    • Location: 0
    • Status: offline
    Re: Biggest weird problem 2014/06/17 06:07:05 (permalink)
    0
    cedric13here is my full program http://www.partage-facile...F2J/v6_main.x.rar.html
    Unfortunately I don't seem to be able to download that.  It also seems very large!
     
     
    here is my full program, but i don't understand your code for a caractere?
    To send an ASCII character to your LCD, it seems you send the high 4 bits first, then the low 4 bits?  I don;t have the datasheet, but that is how it appears from your code.


    I've written you some generic code to do that for any given character, rather than having separate functions to write every single different character you might want.  Your method is very wasteful of space, and not at all flexible.
     
    With a function to write a single character, you can then expand to a function to write a whole string:
    void lcd_write_str (const char* s)
    {
        while (*s != 0)
       {
            lettre (*s++);
        }
    }
     
    //Example usage:
    lcd_write_str("Hello World!");

    #18
    pcbbc
    Super Member
    • Total Posts : 459
    • Reward points : 0
    • Joined: 2014/03/27 07:04:41
    • Location: 0
    • Status: offline
    Re: Biggest weird problem 2014/06/17 06:11:57 (permalink)
    0
    ricAs mentioned above, you are enabling interrupts for eeprom and timer2, but you don't have an interrupt service routine anywhere. That's a recipe for an instant crash.

     
    Ric,
    Do I assume from that response that were able to download the entire project?  And the code still has no ISR?  Are you able to attach the OPs code here for us?  That French download site has got me stumped.
    #19
    ric
    Super Member
    • Total Posts : 22101
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: offline
    Re: Biggest weird problem 2014/06/17 06:16:19 (permalink)
    4 (1)
    The archive is 498kB. It took a bit of poking around with my schoolboy French to download it.
    I can't upload it here, so have parked a copy on picforum. http://picforum.ric323.co...topic.php?f=2&t=52
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #20
    Page: 12 > Showing page 1 of 2
    Jump to:
    © 2018 APG vNext Commercial Version 4.5