Sleep & nap


Closed Thread
Results 1 to 25 of 25

Thread: Sleep & nap

Hybrid View

  1. #1


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Bruce View Post
    Some 18F parts allow you to change config settings at run-time, but I wouldn't advise trying this until you're a bit more familiar with how to set them & what they all do. If you're using a boot-loader, you'll need to know every setting the loader expects, or you may end up doing a lot of loader firmware re-programming. If you search here for modifying config settings on-the-fly you'll find a couple routines showing you how.

    You probably have the latest version then.

    Easy. Open the loader .HEX file with your programmers software. Change it, save the .HEX file, and re-program the loader into your PIC.

    OK. It wasn't shown in the example you posted. Note this won't have anything to do with the WDT or sleep error. Only timing for PBP commands.

    If your programmers software doesn't allow you to read a .HEX file and make changes to config settings, then you can re-compile the loader firmware with the free version of C18.

    Or I can send you a modified version .HEX file if you need it.

    YESSSSS!

    With meProg of course you can change such things, of course. I have just used for "so long time" now only the bootloader so I forgot the meProg.

    Sleep works and NAP works also even that the manual does not confirm that.

    What USB board are you using?
    What is USB board (melabs U2?) or what ? or 4550? or...

  2. #2
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    What is USB board (melabs U2?) or what ? or 4550? or...
    Just curious if you were using a USB development board.

    Did you get it working?
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  3. #3


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Bruce View Post
    Just curious if you were using a USB development board.

    Did you get it working?
    Yep ... it works THANK YOU Bruce

    Both SLEEP and NAP work on 18F4550 !!!! at least on my PIC18F4550 !

    The fault was in the bootloader: WDTPS was too big, 128 is ok

    Thank you all for your help !

    Would a USB development board be good for... what?

  4. #4
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Glad you got it working. It probably was before, but you had to wait a heck of a long time before it would wake up..;o}

    Would a USB development board be good for... what?
    Development boards, like say the Microchip USB dev board & meLabs USB dev boards are handy for testing things quickly without having to build your own boards or hand-wire stuff.

    Definitely not necessary, but handy if you're lazy like me..;o}

    Now that you have the sleep/nap/WDT stuff down pat, here's a fix for your interrupts.

    This isn't what you want;
    DEFINE INTERRUPT_ORG 1008h ' For Microchip USB Bootloader

    It looks like you're using the newer version USB loader, so your interrupts are re-mapped to locations 0x1008 for high priority, and 0x1018 for low priority.

    What you need to do with PBP to make sure it points to these re-mapped vectors goes like this;

    DEFINE RESET_ORG 1000h ' For Microchip USB Bootloader
    DEFINE INTHAND high_isr ' high-pri int vector
    DEFINE INTLHAND low_isr ' low-pri int vector

    Note that you don't need the DEFINE LOADER_USED 1.

    DEFINE RESET_ORG 1000h tells PBP to start compiling all code at 1000h.

    DEFINE INTHAND high_isr. When PBP see this it inserts a ORG RESET_ORG + 8 followed by a goto INTHAND, which is your high_isr routine.

    DEFINE INTLHAND low_isr. Now PBP inserts a ORG RESET_ORG + 18h followed by a goto INTLHAND, which is your low_isr routine.

    So you don't need to specifiy the address.

    Note that your interrupt routines will need to be assembler. Something like this;
    Code:
    asm
    high_isr
      ; do stuff here
      RETFIE FAST
    
    low_isr
      ; do stuff here
      RETFIE
    endasm
    Now your PBP .asm interrupts can work directly with the Microchip USB loader re-mapped int vectors.
    Last edited by Bruce; - 3rd December 2008 at 23:54.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  5. #5


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Bruce View Post
    Glad you got it working. It probably was before, but you had to wait a heck of a long time before it would wake up..;o}


    Development boards, like say the Microchip USB dev board & meLabs USB dev boards are handy for testing things quickly without having to build your own boards or hand-wire stuff.

    Definitely not necessary, but handy if you're lazy like me..;o}

    Now that you have the sleep/nap/WDT stuff down pat, here's a fix for your interrupts.

    This isn't what you want;
    DEFINE INTERRUPT_ORG 1008h ' For Microchip USB Bootloader

    It looks like you're using the newer version USB loader, so your interrupts are re-mapped to locations 0x1008 for high priority, and 0x1018 for low priority.

    What you need to do with PBP to make sure it points to these re-mapped vectors goes like this;

    DEFINE RESET_ORG 1000h ' For Microchip USB Bootloader
    DEFINE INTHAND high_isr ' high-pri int vector
    DEFINE INTLHAND low_isr ' low-pri int vector

    Note that you don't need the DEFINE LOADER_USED 1.

    DEFINE RESET_ORG 1000h tells PBP to start compiling all code at 1000h.

    DEFINE INTHAND high_isr. When PBP see this it inserts a ORG RESET_ORG + 8 followed by a goto INTHAND, which is your high_isr routine.

    DEFINE INTLHAND low_isr. Now PBP inserts a ORG RESET_ORG + 18h followed by a goto INTLHAND, which is your low_isr routine.

    So you don't need to specifiy the address.

    Note that your interrupt routines will need to be assembler. Something like this;
    Code:
    asm
    high_isr
      ; do stuff here
      RETFIE FAST
    
    low_isr
      ; do stuff here
      RETFIE
    endasm
    Now your PBP .asm interrupts can work directly with the Microchip USB loader re-mapped int vectors.
    Thank you Bruce, thank you indeed ... you are really a kind soul !

    By the way,
    can one find somewhere a list of DEFINEs that can be overwritten (changed afterwards whenever you want, when your program runs) and/or those that can not be changed afterwards, like the WTDPS and ... ?

    You "mail" was really educational and clear ... THANK YOU

  6. #6
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    DEFINEs cannot be changed at run-time. These are used by the compiler at compile time
    only.

    WDTPS options are set in the PIC configuration register. These you can change at run-time
    on some 18F parts.

    This thread shows two examples;
    http://www.picbasic.co.uk/forum/show...ghlight=config

    Just bear in mind that changing some configuration settings at run-time may result in major
    problems - so be careful.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

Similar Threads

  1. Won't go back to SLEEP after 1st Interrupt
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 32
    Last Post: - 29th June 2009, 09:00
  2. Battery powered applications
    By NavMicroSystems in forum Off Topic
    Replies: 7
    Last Post: - 22nd June 2009, 07:12
  3. 16F628A current high during sleep
    By Rubicon in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 9th October 2006, 10:21
  4. Wierd sleep issue
    By orca in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 14th March 2006, 22:06
  5. Replies: 5
    Last Post: - 5th February 2006, 16:51

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts