Ultra low power timer

Thread Starter

cmartinez

Joined Jan 17, 2007
8,253
Thanks, MrChips and OBW, but after careful consideration, I think I'll go for the PIC10LF322. It's got everything I need, and by using this chip I can even ditch the external low power timer I was considering. This thing has an internal oscillator of 16MHz, and a secondary low power oscillator of 31 KHz that's an excellent fit for what I'm aiming for.

I've already taken a quick look through it's datasheet, and although it's very different from the 8051 architecture, I think I understood most of it on my first pass. However, I'll be extremely grateful for all help I can get while learning how to tame this tiny beast. Especially from you, OBW. Your familiarity with the PIC12F683 will come in handy because that chip is also very similar to the F322, and uses the same architecture, if I'm not mistaken.
 

OBW0549

Joined Mar 2, 2015
3,566
I've also used the PIC10F322 (as well as its weak sister, the PIC10F200), at least to the level of making a quick "blinkie" with it. It's a nice little chip, (though it doesn't have much memory) good for tiny jobs.
 

OBW0549

Joined Mar 2, 2015
3,566
For your amusement, here's the PIC10F322 "blinkie" program:

Code:
;**********************************************************************
;                                                                     *
;   Basic 10F322 "blinky"-- blinks LED on Port A bit 2                *
;   Derived from 10F222TMPO.ASM                                       *
;                                                                     *
;**********************************************************************
    list      p=10F322            ; list directive to define processor
    #include <p10F322.inc>        ; processor specific variable definitions
;    Configure chip via IDE menu and ignore the following line:
;   __CONFIG   _MCLRE_ON & _CP_OFF & _WDT_OFF & _MCPU_OFF & _IOFSCS_4MHZ
;***** RAM VARIABLES
TEMP_VAR    UDATA
temp1       RES     1
;***** CODE
MAIN    CODE    0x000
    movlw   0x0F
    movwf   LATA            ; preset all outputs to 0
    clrf    ANSELA          ; disable analog inputs
    movlw   0x00            ; set all bits as outputs
    movwf   TRISA
;    movlw   0x0F            ; enable weak pullups on all inputs
;    movwf   WPUA
;    bcf     OPTION_REG, NOT_WPUEN   ; WPU master enable
    clrf    temp1
  
    movlw   0x10
    movwf   OSCCON
    nop
mainloop
    bsf     LATA, LATA2        ; turn the LED on
    movlw   .250            ; set up 1/4 second delay
    movwf   temp1
  
delayloop1
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    decfsz  temp1
    goto    delayloop1
  
    bcf     LATA, LATA2        ; turn the LED off
    movlw   .250            ; set up 1/4 second delay
    movwf   temp1
  
delayloop2
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    decfsz  temp1
    goto    delayloop2
  
    nop
    goto    mainloop
    END                       ; directive 'end of program'
 

Thread Starter

cmartinez

Joined Jan 17, 2007
8,253
For your amusement, here's the PIC10F322 "blinkie" program:

Code:
;**********************************************************************
;                                                                     *
;   Basic 10F322 "blinky"-- blinks LED on Port A bit 2                *
;   Derived from 10F222TMPO.ASM                                       *
;                                                                     *
;**********************************************************************
    list      p=10F322            ; list directive to define processor
    #include <p10F322.inc>        ; processor specific variable definitions
;    Configure chip via IDE menu and ignore the following line:
;   __CONFIG   _MCLRE_ON & _CP_OFF & _WDT_OFF & _MCPU_OFF & _IOFSCS_4MHZ
;***** RAM VARIABLES
TEMP_VAR    UDATA
temp1       RES     1
;***** CODE
MAIN    CODE    0x000
    movlw   0x0F
    movwf   LATA            ; preset all outputs to 0
    clrf    ANSELA          ; disable analog inputs
    movlw   0x00            ; set all bits as outputs
    movwf   TRISA
;    movlw   0x0F            ; enable weak pullups on all inputs
;    movwf   WPUA
;    bcf     OPTION_REG, NOT_WPUEN   ; WPU master enable
    clrf    temp1
 
    movlw   0x10
    movwf   OSCCON
    nop
mainloop
    bsf     LATA, LATA2        ; turn the LED on
    movlw   .250            ; set up 1/4 second delay
    movwf   temp1
 
delayloop1
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    decfsz  temp1
    goto    delayloop1
 
    bcf     LATA, LATA2        ; turn the LED off
    movlw   .250            ; set up 1/4 second delay
    movwf   temp1
 
delayloop2
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    decfsz  temp1
    goto    delayloop2
 
    nop
    goto    mainloop
    END                       ; directive 'end of program'
Excellent! ... many, many thanks! :)
 

Thread Starter

cmartinez

Joined Jan 17, 2007
8,253
Ok, I'm getting ready here. Where can I buy an affordable programmer for the PIC10F322? And where can I download a compiler for it?
I recently built my own programmer for the AT89LP51ED2, so if the programmer is too expensive, I can perfectly fend for myself.
 

OBW0549

Joined Mar 2, 2015
3,566
Yeah... the page says that the PICKit 3 needs an adapter ($50 dlls) to work with the PIC10LF322 ... do you own that adapter as well?
You only need that adapter if you want to do in-circuit debugging with the PK3. For just programming the chip, you don't need it. I rarely use in-circuit debugging anyway, so I don't have one.
 

Thread Starter

cmartinez

Joined Jan 17, 2007
8,253
You only need that adapter if you want to do in-circuit debugging with the PK3. For just programming the chip, you don't need it. I rarely use in-circuit debugging anyway, so I don't have one.
You've just saved me fifty bucks, my friend... I owe you a beer for this, look me up next time you're around my neighborhood . ;)
 

OBW0549

Joined Mar 2, 2015
3,566
You've just saved me fifty bucks, my friend... I owe you a beer for this, look me up next time you're around my neighborhood . ;)
Thanks, I'll remember that!

For programming any of the 8-pin PICs (10F200, 10F322, 12F675, 12F683) I just use a breadboard & a 6-pin header as a programming adapter. For larger chips (14-, 18-, or 28-pin), I either make a programming adapter board or incorporate an ICSP connector into my application design.
 

xox

Joined Sep 8, 2017
838
Question. A while back I was working on a relaxation oscillator circuit that could generate some very long pulses. Unfortunately, I ran into some technical issues that were never quite resolved (the behavior of the circuit didn't always match up with the simulations; in retrospect, that may just because I was using op-amps rather than comparators). That said, I wonder if it could be easily modified to act as a timer (firing fixed, short pulses instead)?
 

Thread Starter

cmartinez

Joined Jan 17, 2007
8,253
Thanks, I'll remember that!

For programming any of the 8-pin PICs (10F200, 10F322, 12F675, 12F683) I just use a breadboard & a 6-pin header as a programming adapter. For larger chips (14-, 18-, or 28-pin), I either make a programming adapter board or incorporate an ICSP connector into my application design.
OB, one question. I've bought the PIC10LF322 which works in a range of 1.8V to 3.6V, but the PIC10F322 works at between 2.3 to 5.5V. Is the PICKit 3 capable of programming both of them, regardless of their working voltage?
 

russ_hensel

Joined Jan 11, 2009
825
That's about the way it's been with me, also. I took a course in C programming many years ago but have never used it other than when fooling around with an Arduino. For everything else, both at work and at play, I've done my programming in assembly language.

It's been my experience that what @MrChips said in post #14 applies very much to assembly language programming: every new chip you learn makes the next one easier. After a half-dozen or so, learning a new one becomes very easy.

One option you might consider is that some of the Microchip's PICs feature what they call an "ultra low-power wake-up" module which can wake the PIC up from Sleep Mode using an internal timer and an external capacitor. The 8-pin PIC12F683 is one part that I have used that has the ULPWU module, which is covered in Microchip's application note AN879.
I started in Fortran in 1967. Programmed in a lot of languages. In my opinion and for my uses, I avoid assembly unless timing is very critical. For microcontrolles I use C ( like arduino pic ) for bigger iron Python. Note that in C you can embed asm for critical parts and that if you use interrupt techniques and timers you can sometimes get very good timing in C alone. C moves much more easily between processors although there still can be plenty of issues. And yes, I have programmed in assembly including hand assembling for the 6502, I never want to do that again.
 

AnalogKid

Joined Aug 1, 2013
11,044
Lordy I miss the 6502, basically an 8-bit, 40-pin PDP11. WAY underappreciated. Fortunately for us, Motorola couldn't kill it when they whacked the 6501.

ak
 
Top