• AVR Freaks

AnsweredHot!Timer0 16 bits

Page: < 12345 > Showing page 2 of 5
Author
Chabb
Starting Member
  • Total Posts : 50
  • Reward points : 0
  • Joined: 2019/11/14 10:16:01
  • Location: 0
  • Status: offline
Re: Timer0 16 bits 2019/11/20 08:57:54 (permalink)
0
1and0. In my program i use timer0 16 bits counting the time (fosc/4). I preload tmr0h whit a number
to obtain an exact time between 2 interrupts but timer0 never counts over 0xFF never gives a carry at
tmr0h. Thank for your help.
#21
1and0
Access is Denied
  • Total Posts : 11110
  • Reward points : 0
  • Joined: 2007/05/06 12:03:20
  • Location: Harry's Gray Matter
  • Status: offline
Re: Timer0 16 bits 2019/11/20 09:42:36 (permalink)
0
Chabb
In my program i use timer0 16 bits counting the time (fosc/4). I preload tmr0h whit a number
to obtain an exact time between 2 interrupts but timer0 never counts over 0xFF never gives a carry at
tmr0h.

I used the code I've posted earlier.  It seems the high byte of Timer0 does not get loaded no matter what value I tried, and TMR0H does not get updated in the Watches/Variables windows even after reading TMR0L; but it takes over 65K cycles for TMR0IF bit to get set.  Post the code you used.
 
Edit: The carry will not propagate into TMR0H. As we told you before, TMR0H is a buffer register of the high byte of the timer.
 
Edit2: In the Watches/Variables windows, TMR0H gets updated to 0x00 (which is wrong) whenever TMR0L is read.  STOP wasting time with the Simulator!
post edited by 1and0 - 2019/11/20 09:58:51
#22
Chabb
Starting Member
  • Total Posts : 50
  • Reward points : 0
  • Joined: 2019/11/14 10:16:01
  • Location: 0
  • Status: offline
Re: Timer0 16 bits 2019/11/20 11:03:53 (permalink)
0
1and0. Ok the case is clear there a bug. 65536 is 2^16 divided by fosc/4 What is your fosc?
#23
1and0
Access is Denied
  • Total Posts : 11110
  • Reward points : 0
  • Joined: 2007/05/06 12:03:20
  • Location: Harry's Gray Matter
  • Status: offline
Re: Timer0 16 bits 2019/11/20 11:08:19 (permalink)
0
Chabb
Ok the case is clear there a bug. 65536 is 2^16 divided by fosc/4 What is your fosc?

The Fosc DOES NOT matter. It is 65536 CYCLES, which is an overflow of a 16-bit number.
 
#24
GeorgePauley
Moderator
  • Total Posts : 1268
  • Reward points : 0
  • Joined: 2009/12/01 13:59:30
  • Location: Chandler AZ
  • Status: offline
Re: Timer0 16 bits 2019/11/20 11:10:41 (permalink)
0
Yep, it's a bug.  It is fixed now and will be available in MPLAB X 5.35.
 
Also, I confirmed my earlier comment.  Reading TMR0H is tricky, you have to read TMR0L first.  So if you are stepping through code, I would not expect TMR0H to have correct value in the watch window.  The simulator is waiting for user code to perform an explicit read of TMR0L before updating TMR0H.
#25
1and0
Access is Denied
  • Total Posts : 11110
  • Reward points : 0
  • Joined: 2007/05/06 12:03:20
  • Location: Harry's Gray Matter
  • Status: offline
Re: Timer0 16 bits 2019/11/20 11:17:55 (permalink)
0
If it's easier to understand, 16-bit TMR0 will take 65536 COUNTS to overflow; i.e. it is equivalent to 65536 cycles since both prescaler and postscaler are set to 1:1.
 
#26
1and0
Access is Denied
  • Total Posts : 11110
  • Reward points : 0
  • Joined: 2007/05/06 12:03:20
  • Location: Harry's Gray Matter
  • Status: offline
Re: Timer0 16 bits 2019/11/20 11:20:33 (permalink)
0
GeorgePauley
Yep, it's a bug.  It is fixed now and will be available in MPLAB X 5.35.
 
Also, I confirmed my earlier comment.  Reading TMR0H is tricky, you have to read TMR0L first.  So if you are stepping through code, I would not expect TMR0H to have correct value in the watch window.  The simulator is waiting for user code to perform an explicit read of TMR0L before updating TMR0H.

As I've said in previous post, with the current MPLAB X 5.30, reading TMR0L updates TMR0H with 0x00.  Have you also implemented the pseduo registers, TMR0_Internal, etc.?
 
Edit: Just curious, which part of the bug is fixed?
post edited by 1and0 - 2019/11/20 12:25:48
#27
1and0
Access is Denied
  • Total Posts : 11110
  • Reward points : 0
  • Joined: 2007/05/06 12:03:20
  • Location: Harry's Gray Matter
  • Status: offline
Re: Timer0 16 bits 2019/11/20 11:34:56 (permalink)
0
With the following code in MPLAB X 5.30:
        #include "p18f25k42.inc"
        config  XINST = OFF
        config  WDTE = OFF
    
        org     0x0000
        movlw   b'00010000'    ; 16-bit timer, postscaler 1:1
        movwf   T0CON0
        movlw   b'01010000'    ; Fosc/4 clock source, asynch, prescaler 1:1
        movwf   T0CON1
        movlw   0xFF           ; TMR0 = 0xFF00
        movwf   TMR0H
        clrf    TMR0L
        bsf     T0CON0,EN      ; Timer0 On (Reset Stopwatch here)
       
        banksel PIR3
        bcf     PIR3,TMR0IF
main    btfsc   PIR3,TMR0IF
        bra     $+2            ; Breakpoint here, Stopwatch cycle count = 81924
  
        movf    TMR0L,w        ; Update TMR0H with 0x00 (wrong)
        bra     main
        end

adding just one line "movf TMR0L,w" causes the TMR0IF flag to set at a count of 81924, instead of the previously 65540... WTF?!  Also, reading TMR0L does NOT update TMR0H (well it changes to 0x00) correctly in both Watches and Variables window.
 
 
post edited by 1and0 - 2019/11/20 11:38:26
#28
Chabb
Starting Member
  • Total Posts : 50
  • Reward points : 0
  • Joined: 2019/11/14 10:16:01
  • Location: 0
  • Status: offline
Re: Timer0 16 bits 2019/11/20 12:29:12 (permalink)
0
Weel your itaration is 4 cycles 2 for btfsc and 2 for bra main. if you note 65536 cycles the itaration run 16384 times. movf take 1cycle. then 65536+16384 = 81920. You note 65536 cycles to obtain tmr0IF 
that proves than timer count 16 bits! Therefore it work correctly whit your program. I have to review my program i dont understand why it not consider tmr0h
 
#29
1and0
Access is Denied
  • Total Posts : 11110
  • Reward points : 0
  • Joined: 2007/05/06 12:03:20
  • Location: Harry's Gray Matter
  • Status: offline
Re: Timer0 16 bits 2019/11/20 12:41:54 (permalink)
+1 (1)
Chabb
Weel your itaration is 4 cycles 2 for btfsc and 2 for bra main. if you note 65536 cycles the itaration run 16384 times. movf take 1cycle. then 65536+16384 = 81920.

Noooooooooo.  TMR0IF should set at overflow of 65536 cycles, not 81920.
 

Therefore it work correctly whit your program. I have to review my program i dont understand why it not consider tmr0h

I did ask you to post your program. I will not ask a 3rd time. ;)
 
#30
1and0
Access is Denied
  • Total Posts : 11110
  • Reward points : 0
  • Joined: 2007/05/06 12:03:20
  • Location: Harry's Gray Matter
  • Status: offline
Re: Timer0 16 bits 2019/11/20 14:04:35 (permalink)
0
Replacing "MOVF TMR0L,W" with a NOP, and TMR0IF set and break at a count of 65539.  Is reading TMR0L inhibit Timer0 by one cycle?  Will check the datasheet later.
#31
dan1138
Super Member
  • Total Posts : 3825
  • Reward points : 0
  • Joined: 2007/02/21 23:04:16
  • Location: 0
  • Status: offline
Re: Timer0 16 bits 2019/11/20 15:41:28 (permalink)
0
In my experience the simulation models for TIMER0 in the PIC18F family have "issues".

From day one the silicon implementation of TIMER0 has some strange quirks that do not affect the other TIMER implementations.

The quirk that caused me the most grief is that a write to the TIMER0 count register delays the timer for 2 instruction cycles. When the prescale is 1:1 this needs to be taken into account for the reload value written to the TIMER0 count register.

Some version of the simulator do not implement this stall for all methods that can write to the TIMER0 count register in the PIC18F architecture.

This post raised the issue of the MPLABX simulator not counting the cycles correctly for an old PIC18F2520.

It would appear that this is not fixable for all of the TIMER0 simulation models.
#32
Chabb
Starting Member
  • Total Posts : 50
  • Reward points : 0
  • Joined: 2019/11/14 10:16:01
  • Location: 0
  • Status: offline
Re: Timer0 16 bits 2019/11/20 17:38:09 (permalink)
0
thank you Dan1138 my program run perfectly whit a Pic 18f2520. I am working to adapt this program for Pic18f25k42 then timer0 has a problem. the reason is : I need a chip having an internal clock 64Mhz.
 
1and0 my program is big 77kb I will try to reduce his size to post it...Tomorrow;  in my house it is 1hour 40 min o clock. bye.
#33
1and0
Access is Denied
  • Total Posts : 11110
  • Reward points : 0
  • Joined: 2007/05/06 12:03:20
  • Location: Harry's Gray Matter
  • Status: offline
Re: Timer0 16 bits 2019/11/20 20:43:06 (permalink)
+1 (1)
dan1138
In my experience the simulation models for TIMER0 in the PIC18F family have "issues".
...
This post raised the issue of the MPLABX simulator not counting the cycles correctly for an old PIC18F2520.

It would appear that this is not fixable for all of the TIMER0 simulation models.

Wow! The case in that post was opened on March 9, 2018. That is over 20 months ago!

Like I said in Post #15 "don't hold your breath." :(
 
I just spent a short time with the PIC18F25K42 Timer0 simulator of the latest MPLAB X v5.30 and already found the following bugs:
  • the high byte of Timer0 is not updated with the contents of TMR0H when a write occurs to TMR0L,
  • TMR0H is not updated with the contents of the high byte of Timer0 during a read of TMR0L,
  • when TMR0L is read, the Timer0 does not increment for one instruction cycle,
  • when TMR0L is written, the Timer0 decrements three instruction cycles -- WTF!
  • TMR0_Internal and TMR0_Prescale pseudo registers do not work,
  • etc.
I've had enough!
 
#34
Chabb
Starting Member
  • Total Posts : 50
  • Reward points : 0
  • Joined: 2019/11/14 10:16:01
  • Location: 0
  • Status: offline
Re: Timer0 16 bits 2019/11/21 04:11:30 (permalink)
0
Hello 1and0 here is my program 19Kb. It is a Music box. out of sleep by int0 that is provided by
stimulus : int0 pulse high 2 cycles. (here also there is a bug: this stimulus work 1 time only and it is locked)
 
;                          BOITE A MUSIQUE ELECTRONIQUE              ;
;......................................................................;
;                          PIC18F25k42                     date:14/03/2015  ;  
;Oscillator : internal RC 32 Mcycles. instruction =3 .125 microsec.     ;
;......................................................................;
;Ports assign   Ra0:   output Load condo Noire                       ;
;               Ra1:   output Load condo croche                      ;
;               Ra2:   output Load condo double croche                     ;
;               Ra3 RA4 ra5 ra7: input not used                      ;
;               Ra6:   clock/4  8Mhz  out                            ;
;                                                                    ;
;               Rb0:   input external interrupt int0                 ;
;               Rb1:   output creneau noire                                ;
;               Rb2:   output creneau croche                         ;
;               rb3:   output creneau double croche                  ;
;               rb4:   output 0 to 3 for shade                       ;
;               rb5:   output 00= forte; 11= pianissimo              ;
;               rb6 rb7 not used                                           ;
;No quartz used. internal oscillator 64 Mhz                                ;
;Codified music registered into program memory starting at line : 384h ;
;Program start at line  Memory : 000; Interrupt vectors at Mem : 008     ;
;Main program begins at line  Mem (Sleep).                           ;
;______________________________________________________________________;
;
    list p=18f25k42, f=inhx32   ;output assembler hexadecimal 8bits
    ;#include p18F25k42.inc
    org 300000       ;configuration of the chip
_config1l = h'8f'     ;internal clock. 64Mhz.
_config1h = h'd5'     
_config2l = h'2d'
_config2h = h'c7'
_config3l = h'9f'
_config3h = h'ff'
_config4l = h'ff'
_config4h = h'df'
_config5l = h'ff'
   
;All protections are disable (No protect)
    org 200000       ;Name of this chip
    __idlocs  h'200000',h'bc'   ;B.C.03 dd 11/2019
    __idlocs  h'200001',h'03'
    __idlocs  h'200002',h'dd'
    __idlocs  h'200003',h'11'
    __idlocs  h'200004',h'aa'
    __idlocs  h'200005',h'20'
    __idlocs  h'200006',h'14'
    __idlocs  h'200007',h'aa'
    ;include 18f25k42.inc
;symbolic values
w    equ  0          ;working register or note nulle
f    equ  1          ;file (Memory position m?moire)
z    equ  2          ;zero (bit z?ro status word)
n    equ  0x00       ;note nulle
;
;Values for counting the time of one half creneau for all possible
;notes used in this program. Complete to 256 (FF+1); boucle= 3.75usec.
la4  equ  0xED       ;Nomber of iterations for; higher note
sol#4 equ  0xEC       ;one half creneau.
sol4 equ  0xEB       ;Hors tol?rance -12.3/1000
fa#4 equ  0xE9       ;Hors tol?rance +20/1000
fa4  equ  0xE8
mi4  equ  0xE7       ;H t -11.2/1000
re#4 equ  0xE5
re4  equ  0xE4       ;H t -13.5/100do#4   equ  0xE2
do#4 equ  0xE2
do4  equ  0xE0       ;Do 2093 239us.  : E0h = 224d
 
si3  equ  0xDE
sib3 equ  0xDC
la3  equ  0xDA       ;La 1760 284us.
sol#3 equ  0xD8
sol3 equ  0xD5       ;Sol 1568 319us. : 43= 213d = d5h
fa#3 equ  0xD3
fa3  equ  0xD0       ;Nomber of iterations for
mi3  equ  0xCD       ;one half creneau
re#3 equ  0xCA
re3  equ  0xC7
do#3 equ  0xC4
do3  equ  0xC0       ;Do 1046
 
si2  equ  0xBD
sib2 equ  0xB8
la2  equ  0xB4       ;La 880
sol#2 equ  0xB0
sol2 equ  0xAB
fa#2 equ  0xA6
fa2  equ  0xA1
mi2  equ  0x9B
re#2 equ  0x95
re2  equ  0x8E
do#2 equ  0x88
do2  equ  0x81       ;Do 523
 
si1  equ  0x79
sib1 equ  0x71
la1  equ  0x68       ;La 440
sol#1 equ  0x5F
sol1 equ  0x56
fa#1 equ  0x4C
fa1  equ  0x41
mi1  equ  0x36
re#1 equ  0x2A
re1  equ  0x1D
do#1 equ  0x0F
do1  equ  0x01            ;The lower note possible
 
;<<<<<<<  special function Registers used  >>>>>>>
tmr0l equ  0x3fb6          ;timer0 low
tmr0h equ  0x3fb7          ;OK timer0 hight
pir1 equ  0x39a1          ;pir1 bit 0 : int0 occured
pie1 equ  0x3991          ;enable ext int0
pir3 equ  0x39a3          ;pir3 bit 7 : tmr0 int. occured
pie3 equ  0x3993          ;enable timer0 interrupt
ipr1 equ  0x3981
status     equ  0x3884     ;adresse du mot status
porta equ  0x3fca          ;OK adresse port A
lata equ  0x3fba    
portb equ  0x3fcb          ;adresse port B
latb equ  0x3fbb    
trisa equ  0x3fc2          ;config port A
trisb equ  0x3fc3          ;config port B
bsr  equ  0x3fe0          ;bank select   
intcon0    equ  0x3fd2     ;interrupt control
int0pps    equ  0x3ac0     ;extern.int. on rb0 
t0con0     equ  0x3fb8     ; timer0 control 0
t0con1     equ  0x3fb9     ;timer0 control 1   
osccon1    equ  0x39d9     ;oscillator control
osctune    equ  0x39de     ;adjust internal oscillator 64 Mhz
 
;<<<<<<<  Files registers used by this program  >>>>>>>
                     ;0x01 = do1
n0   equ  0x02       ;n0 for Tempo
n1   equ  0x03       ;n1 to n7 = time 1/2 cr?neau
n2   equ  0x04       ;for a writed note
n3   equ  0x05
n4   equ  0x06
n5   equ  0x07
n6   equ  0x08
n7   equ  0x09
frdc1 equ  0x0a       ;freq. first double croche
frdc2 equ  0x0b       ;freq. second double croche
frdc3 equ  0x0c       ;freq. third double croche
frdc4 equ  0x0d       ;freq. fourth double croche
frc1 equ  0x0e       ;freq. first croche
                     ;0x0f = do#1
frc2 equ  0x10       ;freq. second croche
frn  equ  0x11       ;freq. noire
countdc    equ  0x12       ;counter double croche
countc     equ  0x13       ;counter croche
countn     equ  0x14       ;counter noire
cint equ  0x15       ;count 0 to 16 = 1 TEMPS = 1 noire
del  equ  0x16       ;count delai (20 = 1 sec.)
tempo equ  0x17       ;unfolding speed (rapidit?) Tempo
count1     equ  0x18       ;count delais
count2     equ  0x19       ;  "      "
rep  equ  0x1a       ;control repeate in song
ped  equ  0x1b       ;continue noire r?sonent
newsong    equ  0x1c ;bypass song or start music
                     ;0x1d = re1
bitest     equ  0x1e ;[ bit  1    2    3     4      5    6     7
                            ;[     dc1   c1   n   dc2  dc3  c2   dc4
song equ  0x1f       ;to see the progress in MPLAB
 
 
;Glossary : english 1/4 semi breve = amer.1/4 whole note = fr. noire
     ; or eng. crotchet = amer.quarter note = fr. noire
     ;eng. quaver = amer. eighth note = fr. croche
     ;amer. sixteenth note = fr. double croche
     ;La = A;  Si = B;  Do = C;  Re = D;  Mi = E;  Fa = F;  Sol = G
 
;<<<<<<<<< MACROS>>>>>>>>
delais     macro arg1 ;macro delais. argument contains
    movlw  arg1       ;the time number to run
    movwf  del
    call   DELAI      ;50millisec. * del
    endm
 
unload     macro
    movlw  d'14'      ;0E hexa 00001110
    movwf  portb      ;discharge condos
    clrf   cint
    clrf   ped,f
    clrf   rep,f
    endm
 
Forte macro           ;Forte
    bcf    portb,5
    bcf    portb,4
    endm
 
Mf   macro           ;Mezzoforte
    bcf    portb,5
    bsf    portb,4
    endm
 
Piano macro           ;Piano
    bsf    portb,5
    bcf    portb,4
    endm
 
Pp   macro           ;Pianissimo
    bsf    portb,5
    bsf    portb,4
    endm
 
pedon macro           ;Pedal on
    bsf    ped,0
    endm
 
repris     macro go_on      ;Repeat at. Reprise ?
    bsf    rep,0
    goto   go_on
    endm
 
repris2    macro go_on      ;Repeat2
    bsf    rep,1
    goto   go_on
    endm
 
sectim     macro go_to      ;Second Time used with repris
    btfss  rep,0           ;Skip first step to second step
    bra    $+6             ;and continue
    bcf    rep,0
    goto   go_to
    endm
 
sectim2    macro go_to      ;option of repeat2
    btfss  rep,1
    bra    $+6
    bcf    rep,1
    goto   go_to
    endm
 
;<<<<<<<loading frequences for notes in one step (noire)>>>>>>>
temps macro nn0,nn1,nn2,nn3,nn4,nn5,nn6,nn7 ;in 1 step:
    movlw  nn0        ;nn0 = tempo
    movwf  n0
    movlw  nn1        ;nn1 = first double croche
    movwf  n1
    movlw  nn2        ;nn2 = first croche
    movwf  n2
    movlw  nn3        ;nn3 = noire
    movwf  n3
    movlw  nn4        ;nn4 = second double croche
    movwf  n4
    movlw  nn5        ;nn5 = third double croche
    movwf  n5
    movlw  nn6        ;nn6 = second croche
    movwf  n6
    movlw  nn7        ;nn7 = fourth double croche
    movwf  n7
    call   loadfr
    endm
 
    org 0x00
;................Biginning of program  at adress 0................
 
Init1                ;Initialization at power on
    movlw  h'00'      ; disable interrupt
    movwf  intcon0
    movlw  h'90'      ;timer0 enable 16 bits postcal 1/1
    bra    afterir    ;mem 1E skip interrupt routine and interrupt ;vectors
;................Intrrupt vectors at adress 8 .....................
ivect da  0x0012     ;0mem 8
     da  0x0012
     da  0x0012
     da  0x0012
     da  0x0012
     da  0x0012
     da  0x0012
     da  0x0012
     da  0x0012     ;int0
     da  0x0012
     da  0x0012    
     da  0x0012
     da  0x0012
     da  0x0012
     da  0x0012
     da  0x0012
     da  0x0012
     da  0x0012
     da  0x0012
     da  0x0012
     da  0x0012
     da  0x0012
     da  0x0012 
     da  0x0012
     da  0x0012
     da  0x0012
     da  0x0012
     da  0x0012
     da  0x0012
     da  0x0012
     da  0x0012
     da  0x0012          ;tmr 0
        
introut movlb   h'39'      ;add mem 28h bsr= 39h bank 57
     btfss pir3,7,1        ;is tmr0 overflow? introut = 1.375 microsec
     bra  $+d'18'         ;no
     bcf  pir3,7,1        ;yes clear flag tmr0 overflow
     movlb h'00'
     incf cint,1          ;+1 on counter tempo
     movf tempo,0
     movwf tmr0h           ;refresh preload tmr0 hight byte
     ;clrf tmr0h
     clrf tmr0l
     movf tmr0l,0         ;to update timer0 high byte
     bra  $+d'14'         ;out Introut
     movlb h'39'
     bcf  pir1,0,1        ;it is int0 (start button) clear flag
     movlb 0
     bsf  newsong,0       ;set bit 0
     movlw h'81'
     movwf intcon0         ;enable global interrupt; int0
     retfie     1          ;restore W, Status, BSR     
 
afterir    movwf t0con0     ;90= tmr0 16 bits postscal 1/1 enable
     movlw h'44'
     movwf t0con1          ;fosc/4 prescal 1/16
     movlb h'39'           ;bank 57
     bsf  pie1,0,1        ;enable ext. int0 rb0 high pulse
     bsf  pie3,7,1        ;timer0 enable int.
     bsf  ipr1,0,1
     movlw h'60'           ;enter sleep mode on SLEEP instruction
     movwf osccon1,1 
    movlb 0               ;bank 0
     movlw h'08'           ;port A 3 in 0-1-2 out  \
     movwf trisa           ;init tris a 00001000   /
     movlw h'c1'           ;port B 0 in 1 to 5 out \
     movwf trisb           ;init tris b 11000001   /
    
Init2
     clrf tmr0h
     clrf tmr0l      ;tmr0 low
    clrf   porta      ;init port A
    clrf   portb      ;init port B
    clrf   countdc    ;clear counters 0 to 255
    clrf   countc
    clrf   countn
    clrf   cint       ;clear timer for one step 0 to 16
    clrf   rep        ;for repeate
    bsf    t0con0,7   ;enable timer0
    bsf    t0con0,4   ;timer0 16bits
    bcf    intcon0,0  ;int. on falling edge
    movlw  h'81'      ;enable global interrupt int0
    movwf  intcon0
    delais 1          ;70ms.pwrt is not eneuf
    clrf   newsong    ;bit 0 is memory start button
;...............................End initialization ...............
 
sle sleep            ;wait start button depressed ext.INT0
    nop                   
    btfss  newsong,0
    bra    sle
depart     clrf porta      ;Load capa = 0
     clrf song            ;to see in MPLAB
     clrf newsong
     clrf tempo
     clrf cint
     clrf countdc
     clrf countc
     clrf countn
     unload               ;unload capa's
     incf song,1          ;to follow in MPLAB
     call  song1           ;song number one
     unload
    incf song,1
    call song2      ;song number 2
     unload
    incf song,1
    call song3      ;song number 3
     unload
    incf song,f
    call song4      ;song number 4
     unload
    incf song,f
    call song5      ;song number 5
     unload
    incf song,f
    call song6      ;song number 6
     unload
    incf song,f
    call song7      ;song number 7
     unload
    incf song,f
     call song8      ;song number 8 Your song
    goto sle        ;wait start button
;
;here is the program to execute music.
;
;
;____________________________Enf of program____________________
 
song1                ;Adorable musique Mozart
     delais     10         ;(La flute enchantee)
     Mf   ;mezzo forte
c1part1         ;Tmp   Dc1   C1    N     Dc2   Dc3   C2    Dc4
c1m1.1     temps d'230',sol3 ,n    ,n    ,fa3  ,n    ,mi3  ,n
c1m1.2     temps n     ,n    ,n    ,mi3  ,n    ,n    ,n    ,n
c1m1.3     temps n     ,n    ,mi3  ,n    ,n    ,n    ,fa3  ,n
c1m1.4     temps n     ,n    ,n    ,fa3  ,n    ,n    ,n    ,n
c1m2.1     temps n     ,fa3  ,n    ,n    ,mi3  ,n    ,re3  ,n
c1m2.2     temps n     ,n    ,n    ,re3  ,n    ,n    ,n    ,n
c1m2.3     temps d'115',n    ,n    ,re3  ,n    ,n    ,n    ,n
c1m2.4     temps n     ,n    ,n    ,mi3  ,n    ,n    ,n    ,n
     pedon
c1m2.5     temps d'230',n    ,n    ,n    ,n    ,sol3 ,n    ,fa3
c1m3.1     temps n     ,n    ,n    ,mi3  ,n    ,n    ,n    ,n
c1m3.2     temps n     ,n    ,n    ,mi3  ,n    ,n    ,mi3  ,n
     Forte ;Forte
c1m3.3     temps n     ,n    ,n    ,fa3  ,n    ,n    ,n    ,sol3
c1m3.4     temps n     ,n    ,la3  ,n    ,n    ,n    ,fa3  ,n
c1m4.1     temps n     ,n    ,n    ,mi3  ,n    ,n    ,n    ,n
     Mf   ;mezzo forte
c1m4.2     temps n     ,n    ,n    ,re3  ,n    ,n    ,n    ,re3
c1m4.3     temps n     ,n    ,n    ,do3  ,n    ,n    ,n    ,n
     sectim     c1m8.4
c1part2
     Piano ;Piano
     pedon ;Tmp   Dc1   C1    N     Dc2   Dc3   C2    Dc4
c1m4.4     temps n     ,n    ,n    ,n    ,n    ,fa3  ,n    ,mi3
c1m5.1     temps n     ,n    ,n    ,re3  ,n    ,n    ,re3  ,n
     pedon
c1m5.2     temps n     ,n    ,n    ,n    ,n    ,n    ,re3  ,n
c1m5.3     temps n     ,n    ,n    ,mi3  ,n    ,n    ,mi3  ,n
     pedon
c1m5.4     temps n     ,n    ,n    ,n    ,n    ,n    ,mi3  ,n
c1m6.1     temps n     ,n    ,n    ,fa3  ,n    ,n    ,n    ,n
c1m6.2     temps n     ,n    ,fa3  ,n    ,n    ,n    ,n    ,sol3
c1m6.3     temps n     ,n    ,n    ,mi3  ,n    ,n    ,n    ,n
     pedon
c1m6.4     temps n     ,n    ,n    ,n    ,n    ,mi3  ,n    ,fa3
     Mf   ;MF
c1m7.1     temps n     ,n    ,n    ,sol3 ,n    ,n    ,n    ,n
c1m7.2     temps n     ,n    ,sol3 ,n    ,n    ,n    ,sol3 ,n
     Forte ;F
c1m7.3     temps n     ,n    ,la3  ,n    ,n    ,n    ,n    ,si3
c1m7.4     temps n     ,n    ,do4  ,n    ,n    ,n    ,fa3  ,n
     Mf   ;MF
c1m8.1     temps n     ,n    ,n    ,mi3  ,n    ,n    ,n    ,n
c1m8.2     temps n     ,n    ,n    ,re3  ,n    ,n    ,n    ,re3
     Pp   ;Pp
c1m8.3     temps n     ,n    ,n    ,do3  ,n    ,n    ,n    ,n
     repris     c1part1
c1m8.4     pedon
     temps n     ,n    ,n    ,n    ,n    ,n    ,n    ,n
 
    return
;_________________________________________________________________
;Continue with 7 other songs.
    end    ;Music for a quarter of an hour.
 
 
 
 
 
 
#35
1and0
Access is Denied
  • Total Posts : 11110
  • Reward points : 0
  • Joined: 2007/05/06 12:03:20
  • Location: Harry's Gray Matter
  • Status: offline
Re: Timer0 16 bits 2019/11/21 04:58:19 (permalink)
0
I'm not going to criticize your program, because it would be a long list. ;)
 
Anyway, your Timer0 is setup as a 16-bit timer with a prescaler of 1:16. That is, 65536 * 16 = 1,048,576 instruction cycles. I briefly tested your program (commented out a few routine calls since they are not provided) just now and Timer0 interrupt at a rate of 1,048,577 cycles according to the Simulator Stopwatch. So, what is the problem?
#36
1and0
Access is Denied
  • Total Posts : 11110
  • Reward points : 0
  • Joined: 2007/05/06 12:03:20
  • Location: Harry's Gray Matter
  • Status: offline
Re: Timer0 16 bits 2019/11/21 05:11:03 (permalink)
0
Here's a screenshot:
Attachments are not available: Download requirements not met  

Attachment(s)

Attachments are not available: Download requirements not met
#37
Chabb
Starting Member
  • Total Posts : 50
  • Reward points : 0
  • Joined: 2019/11/14 10:16:01
  • Location: 0
  • Status: offline
Re: Timer0 16 bits 2019/11/21 08:29:01 (permalink)
0
Thank you very much testing my program therefore there is no problem whit timer0? Ok I look for an error in my program. Regards.
 
#38
Chabb
Starting Member
  • Total Posts : 50
  • Reward points : 0
  • Joined: 2019/11/14 10:16:01
  • Location: 0
  • Status: offline
Re: Timer0 16 bits 2019/12/02 09:32:52 (permalink)
0
Hello
Now my program runs well; it was just necessary I undestand that windows SFR register and Files register are not updated... stimulus is some time loocked...Apart from that, everything's fine.
But ma program runs iteratively for 1/4 of an hour ( in real time, many hours in mplabx). in mplabx it runs 3-4 minutes then it falls down initialised pc count = 00. I put a breack point at memory 00. No instruction do that.
Is there a limitation of time running or numfer of instruction or number of cycles? Have you experienced this fact? thank you.
post edited by Chabb - 2019/12/02 09:37:50
#39
1and0
Access is Denied
  • Total Posts : 11110
  • Reward points : 0
  • Joined: 2007/05/06 12:03:20
  • Location: Harry's Gray Matter
  • Status: offline
Re: Timer0 16 bits 2019/12/02 10:29:51 (permalink)
+1 (1)
Chabb
Now my program runs well; it was just necessary I undestand that windows SFR register and Files register are not updated... stimulus is some time loocked...Apart from that, everything's fine.

Sound like bugs with the MPLAB X and/or its Simulator.
 

But ma program runs iteratively for 1/4 of an hour ( in real time, many hours in mplabx). in mplabx it runs 3-4 minutes then it falls down initialised pc count = 00. I put a breack point at memory 00. No instruction do that.
Is there a limitation of time running or numfer of instruction or number of cycles? Have you experienced this fact?

Is the Watchdog Timer off?
 
#40
Page: < 12345 > Showing page 2 of 5
Jump to:
© 2020 APG vNext Commercial Version 4.5