• AVR Freaks

Hot!dspic33_TMR1

Author
ft.ovah
Starting Member
  • Total Posts : 53
  • Reward points : 0
  • Joined: 2020/01/10 06:17:03
  • Location: 0
  • Status: offline
2020/04/02 08:55:36 (permalink)
0

dspic33_TMR1

Hi,
Im using dspic33ck256mp205,in my timer after it matches the value in PR1,its doesnt go to the interrupt even though ive enabled the global interrupt bit ,Also i want to set a timer of 10us but i am not able to do it.Can someone be kind enough to help me out ?
 

    .equ __33CK256MP205, 1
        .include "p33CK256MP205.inc"

;..............................................................................
;Configuration bits: We will use the MPLAB menu to configure the bits
;..............................................................................

;..............................................................................
;Program Specific Constants (literals used in code)
;..............................................................................

     ;   .equ SAMPLES, 64         ;Number of samples


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

        ;.global _wreg_init                        ;Provide global scope to _wreg_init routine
                                                          ;In order to call this routine from a C file,
                                                         ;place "wreg_init" in an "extern" declaration
                                                         ;in the C file.
 
        .global __reset          ;The label for the first line of code.

        



;..............................................................................
;Constants stored in Program space
;..............................................................................

        .section .myconstbuffer, code
        .palign 2                                                         ;Align next word stored in Program space to an
                                                                             ;address that is a multiple of 2
ps_coeff:
        .hword   0x0002, 0x0003, 0x0005, 0x000A




;..............................................................................
;Uninitialized variables in X-space in data memory
;..............................................................................

 ;        .section .xbss, bss, xmemory
;x_input: .space 2*SAMPLES                          ;Allocating space (in bytes) to variable.


;..............................................................................
;Uninitialized variables in Y-space in data memory
;..............................................................................

  ;        .section .ybss, bss, ymemory
;y_input:  .space 2*SAMPLES



;..............................................................................
;Uninitialized variables in Near data memory (Lower 8Kb of RAM)
;..............................................................................

 ;         .section .nbss, bss, near
;var1:     .space 2                                             ;Example of allocating 1 word of space for
                                                                     ;variable "var1".



;..............................................................................
;Code Section in Program Memory
;..............................................................................
                
   
    .text                                                        ;Start of Code section
__reset:
                                                                   ; First initialize the stack pointer and the Stack pointer limit
        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
    
;...............................................................
;             Initialization
;...............................................................
;-------TIMER1-------------
    
              CLR       TMR1
          MOV    #0X70,W0
          MOV    W0,IPC0
          MOV    #0X50,W0                        ; Load the Period register
          MOV    w0, PR1
          BSET    IEC0,#T1IE
          BCLR    IFS0,#T1IF
          BSET    T1CON,#TON
          
          
          
          
          GOTO      MAIN_LOOP
         
;--------------------------------------------------------------
MAIN_LOOP:
           
    

        bra          MAIN_LOOP
    
    

        
    
__T1Interrupt:
    
    BCLR        IFS0,#T1IF
    
    
    RETFIE                
                
                
                


;--------End of All Code Sections ---------------------------------------------

.end                               ;End of program code in this f    
    
    
    
   
#1

5 Replies Related Threads

    ft.ovah
    Starting Member
    • Total Posts : 53
    • Reward points : 0
    • Joined: 2020/01/10 06:17:03
    • Location: 0
    • Status: offline
    Re: dspic33_TMR1 2020/04/02 11:15:23 (permalink)
    0
    Apparently there is no GIE bit in dspic30f which i did a bit of coding in, so i went through the dspic33 interrupts and i got it ,but i still have issues relating to timer value setting .
    #2
    ric
    Super Member
    • Total Posts : 26942
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: dspic33_TMR1 2020/04/02 12:30:02 (permalink)
    0
    Are you testing this on real hardware, or on a simulator?
    As you're interrupt service does nothing other than clear the interrupt request flag, you wouldn't know what was happening on real hardware.
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #3
    ft.ovah
    Starting Member
    • Total Posts : 53
    • Reward points : 0
    • Joined: 2020/01/10 06:17:03
    • Location: 0
    • Status: offline
    Re: dspic33_TMR1 2020/04/03 00:59:58 (permalink)
    0
    Yes, your right I'm just trying to simulate it and adjust the timer speed, for now, can't test it on the bench since I haven't ordered the dspic33 variant and also because of these times...does the simulator not show the exact timer period? I should be getting a calculated period of 1us if I put 0x31 into the pr1 register if fosc/2 which is 50Mhz , but I'm getting a value of 48us and 52us instead ? does this have to with the oscillator settings, that too should only effect when I'm using real hardware, not on the simulator.
    #4
    ric
    Super Member
    • Total Posts : 26942
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: dspic33_TMR1 2020/04/03 01:23:24 (permalink)
    0
    I've not used the simulator much, but I believe it is your job to tell the simulator how fast the chip is running, it does NOT analyse your oscillator settings.
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #5
    ft.ovah
    Starting Member
    • Total Posts : 53
    • Reward points : 0
    • Joined: 2020/01/10 06:17:03
    • Location: 0
    • Status: offline
    Re: dspic33_TMR1 2020/04/03 02:08:25 (permalink)
    0
    Thanks ric,how stupid of me, i actually forgot about the simulator frequency in mplab, My bad !
    #6
    Jump to:
    © 2020 APG vNext Commercial Version 4.5