piclist 2005\08\24\180933a >
Thread: ds30F demo program
www.piclist.com/techref/microchip/devices.htm?key=pic
picon face BY : John Nall email (remove spam text)



Wouter van Ooijen wrote:

>One part of the grunt work is that debugging the programmer would
>require a know-working blink-a-led program for every taget chip. My
>blink-a-led page does not have any 30F's, so creating such programs
>would do a favour to every starter.
>  
>

OK, here you go.  Sorry it took so long.  Doesn't take very long to
write a blink-a-led program, even if some things have changed with the
30F instruction set.  But it took a bit longer to figure out how the
timer on the 30F3013 works -- it is a bit different from the 18F452,
which is what I used before. :-)  Anyway, this one works fine on the
30F3013 running a 7.68 Mhz crystal and using the 4 x PLL option..  
Blinks an led on and off  at one-second intervals.  I have included the
source code -- not because I figure you want it, but because someone who
is just getting interested in the 30F family might find it useful.  And
yes, I KNOW I did not use good programming techniques --  this was quick
and dirty (but works).

John
-------------------------------------------------------------------------------------------------------------
:020000040000fa
:080000000001040000000000f3
:020000040000fa
:100200000f80200080ff2000000188000000000017
:100210004401020000000000d622ef00d222ef00cd
:10022000d422ef00f0ff2f0040158800d702a8006d
:100230002001020000000000d702aa00fcff3700e6
:1002400070102700100888000421ef000021ef0043
:100250000481a80004a1a8009580a80095a0a90089
:1002600095c0a9008460a9008c60a80005e1a800e1
:100270000140fe008c60a90005e1a9000000060015
:100280008460a900004006000000eb000007780031
:100290000c000900002f78000007eb0000000600aa
:020000040000fa
:0200000401f009
:04000000e5ff000018
:020000040000fa
:0200000401f009
:04000400ff7f00007a
:020000040000fa
:0200000401f009
:04000800eeff000007
:020000040000fa
:0200000401f009
:04001400ffff0000ea
:020000040000fa
:10000800520100005201000052010000520100009c
:10001800520100005201000052010000520100008c
:10002800520100005201000052010000400100008e
:10003800520100005201000052010000520100006c
:10004800520100005201000052010000520100005c
:10005800520100005201000052010000520100004c
:10006800520100005201000052010000520100003c
:10007800520100005201000052010000520100002c
:10008800520100005201000052010000520100001c
:10009800520100005201000052010000520100000c
:1000a80052010000520100005201000052010000fc
:1000b80052010000520100005201000052010000ec
:1000c80052010000520100005201000052010000dc
:1000d80052010000520100005201000052010000cc
:1000e80052010000520100005201000052010000bc
:0800f80052010000520100005a
:020000040000fa
:10010800520100005201000052010000520100009b
:10011800520100005201000052010000520100008b
:10012800520100005201000052010000400100008d
:10013800520100005201000052010000520100006b
:10014800520100005201000052010000520100005b
:10015800520100005201000052010000520100004b
:10016800520100005201000052010000520100003b
:10017800520100005201000052010000520100002b
:10018800520100005201000052010000520100001b
:10019800520100005201000052010000520100000b
:1001a80052010000520100005201000052010000fb
:1001b80052010000520100005201000052010000eb
:1001c80052010000520100005201000052010000db
:1001d80052010000520100005201000052010000cb
:1001e80052010000520100005201000052010000bb
:0801f800520100005201000059
:020000040000fa
:0402a000000000005a
:020000040000fa
:0402a4000000fe0058
:00000001FF
--------------------------------------------------------------------------------------
;     Source - assembled with MPASM, utilizing the files
;           included with MPLAB IDE 7.20
;
;     Blink an LED (attached to pin RD8)
;        Written specifically for ds30F3013 but will probably
;        work on other models of that family also with little change
required.                                    
;                                                                            
*
;    Other Files Required: p303013.gld,
p30f3013.inc                         *

       .equ __30F3013, 1
       .include "p30f3013.inc"

;..............................................................................
;Configuration bits:
;..............................................................................

       config __FOSC, CSW_FSCM_OFF & XT_PLL4    ;Turn off clock
switching and
                                           ;fail-safe clock monitoring and
                                           ;use the External Clock as the
                                           ;system clock with 4x PLL

       config __FWDT, WDT_OFF              ;Turn off Watchdog Timer

       config __FBORPOR, PBOR_ON & BORV_27 & PWRT_16 & MCLR_EN
                                           ;Set Brown-out Reset voltage and
                                           ;and set Power-up Timer to
16msecs
                                         
       config __FGS, CODE_PROT_OFF         ;Set Code Protection Off for
the
                                           ;General Segment

;..............................................................................
;Global Declarations:
;..............................................................................

       .global _wreg_init       ;Provide global scope to _wreg_init routine
                               
       .global __reset          ;The label for the first line of code.

       .global __T1Interrupt    ;Declare Timer 1 ISR name global


.text                             ;Start of Code section
__reset:
       MOV #__SP_init, W15       ;Initalize the Stack Pointer
       MOV #__SPLIM_init, W0     ;Initialize the Stack Pointer Limit
Register
       MOV W0, SPLIM
       NOP                       ;Add NOP to follow SPLIM initialization
     
       CALL _wreg_init           ;Call _wreg_init subroutine
                               
       clr    LATD                     ; set up for output, utilizing PORTD
       clr    TRISD
       clr PORTD

       mov    #0xFFFF,w0
       mov    w0,ADPCFG            ; set all analog pins to digital

       bset LATD,#RD8            ; RD8 has the honor to be selected to
blink

Loop:
       call d_1_sec            ; delay for one second

       btg LATD,#RD8            ; toggle the bit to turn LED on/off
       bra     Loop                ; endless loop



d_1_sec:    mov #28935,w0        ; delay constant for one second
                               ; using 7.38 MHz crystal and 4xPLL
                               ; (135 nanoseconds per instruction)
           mov    w0,PR1
     
       clr    T1CON                           ; clear Timer1 control
register
       clr    TMR1                              ; clear Timer1 count
register

       bset    T1CON,#TCKPS0
       bset    T1CON,#TCKPS1        ;    select 1:256 prescaler

       bset    IPC0,#T1IP0            ;  setup Timer1 interrupt for
       bclr    IPC0,#T1IP1            ;  level 1 priority
       bclr    IPC0,#T1IP2          

       bclr    IFS0,#T1IF            ;  Clear Timer1 interrupt status flag
       bset    IEC0,#T1IE            ;  Enable Timer1 interrupts

       bset    T1CON,#TON            ; start timer with prescaler set
to 1:256
       pwrsav    #1                    ; go into idle mode
                                              ; until Timer causes
interrupt

       bclr    IEC0,#T1IE            ; disable Timer1 interrupts
       bclr    T1CON,#TON            ; disable timer
       return

__T1Interrupt:
       bclr    IFS0,#T1IF
       retfie


_wreg_init:
       CLR W0
       MOV W0, W14
       REPEAT #12
       MOV W0, [++W14]
       CLR W14
       RETURN

.end                               ;End of program code in this file




<430CF012.9030309@gmail.com> 7bit

In reply to: <000101c5a6df$d70f0210$0b00a8c0@PAARD>
See also: www.piclist.com/techref/microchip/devices.htm?key=pic
Reply You must be a member of the piclist mailing list (not only a www.piclist.com member) to post to the piclist. This form requires JavaScript and a browser/email client that can handle form mailto: posts.
Subject (change) ds30F demo program

month overview.

new search...