PIC18F13K50, CDC USB communication and ultra-low power temperature logger


Closed Thread
Results 1 to 28 of 28

Hybrid View

  1. #1
    Join Date
    Jan 2009
    Location
    Miami, Florida USA
    Posts
    704

    Default

    Quote Originally Posted by aberco View Post
    Looks good on the paper, now onto the program to get this. I still need to fix the USB side first though...
    Aberco,

    It would be interesting to see a Battery vs. Time plot after you are done with your design to see how well the battery is holding on.

    Robert
    "No one is completely worthless. They can always serve as a bad example."

    Anonymous

  2. #2
    Join Date
    Dec 2007
    Location
    Paris
    Posts
    101

    Default

    Yep will do!
    I have setup the secondary oscillator with a 32k XTal. That way it will give me the time accuracy I need and I can clock the CPU using that source. I have yet to finish the main routine and get everything to work before implementing the power conservation tricks.... and that USB communication deal to figure out.

  3. #3
    Join Date
    Dec 2007
    Location
    Paris
    Posts
    101

    Default

    It was time to pack things down, I must say that it is not easy to drill vias using a 0.3mm drillbit and sticking a tiny copper wire in it to make the connexion!



    Not much progress on the programming yet due to lack of free time, but will work on that soon.

  4. #4
    Join Date
    Dec 2007
    Location
    Paris
    Posts
    101

    Default

    Back with more news, I made some great progress with the programming!

    I am trying to implement the low power mode, however I find microchip datasheet to be a bit confusing. I switch from a 48Mhz CPU clocked from 12MHz HS primary oscillator + PLL to the Timer1 clock source (SEC_RUN mode) when entering low power operation:

    Code:
    'Oscillator software configuration for 32.768kHz operation on Timer1 clock
    OSCCON.1 = 0
    OSCCON.0 = 1 'Use Timer1 oscillator as clock source
    OSCTUNE.6 = 0 'Disable PLL
    OSCCON2.2 = 0 'Disable primary oscillator
    OSCCON.7 = 1 'Device enters in IDLE mode when sleep instruction issued
    Then I have my main standalone operation loop. The only code executing are triggered by INT0 and TMR1 using DT_INTS-18.

    Code:
    StandAloneLoop:
    
    @ SLEEP
    
    GOTO StandAloneLoop
    It does work well if the operating mode is IDLE (IDLEN = 1). This mode turn off CPU clock but leave all peripheral clocked (here, from Timer1 source). I tried this instead:

    Code:
    OSCCON.7 = 0 'Device enters in SLEEP mode when sleep instruction issued
    This would allows to save even more by turning off the peripheral too, however the first interruption does work, and after the PIC doesn't wake up anymore. In the datasheet it says
    This shuts down the selected oscillator and all clock source status bits are cleared.
    However the only peripheral that needs to run is the Timer1 to trigger the interrupt, but that can only happen if the secondary oscillator is running. If there's no way to use SLEEP mode while keeping the secondary oscillator running, then I should probably use the SEC_IDLE mode... hopefully the peripherals don't drain that much power.

  5. #5
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959

    Default

    If you put a crystal on the Timer1 oscillator, enable T1OSCEN and change TMR1CS before going to sleep with an appropriate reload value for the lower frequency ... you could put it to sleep.
    DT

  6. #6
    Join Date
    Dec 2007
    Location
    Paris
    Posts
    101

    Default

    Hmm I don't really understand, I have this at the beginning of my code during initialization:

    Code:
    T1CON = %01101011 'Set Timer prescaler to /4 and enable Timer1 on external 32768Hz crystal
    T1OSCEN = 1 (secondary 32768Hz oscillator is enabled)
    TMR1CS = 1 (timer clock source is secondary 32768Hz oscillator)

    My setup already use the Timer1 for both interrupt and general clock source when in low power mode, and it does work as expected.

    I tried to add that T1CON configuration line above my @ SLEEP instruction but that didn't help much. If the SLEEP mode actually turn off all clocking sources then T1OSCEN bit should be set to 0 as well.

    Maybe using the IDLE mode and manually disable all peripherals that are enabled default would be a workaround.

  7. #7
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959

    Default

    Timer1 oscillator continues to run during sleep mode, but ... try it like this.
    First, comment all the OSCCON and OSCTUNE statements you showed above.

    Then ...
    Code:
    StandAloneLoop:
      ASM
        SLEEP
        NOP
        NOP
      ENDASM
    GOTO StandAloneLoop
    DT

Members who have read this thread : 0

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

Tags for this Thread

Posting Permissions

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