PM Asembler and Melab U2 Programmer Problems with PIC16F1939


Closed Thread
Results 1 to 13 of 13

Hybrid View

  1. #1
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    If you have PBP lines in your ISR, I'd say go for your second example.

    What kind of interrrupt it is? Remember that ON INTERRUPT will jump in your ISR ONLY after finishing a x current job. So if you have, say PAUSE 5000, in your main loop, it may take up to 5 secondes to jump in the ISR (assuming your main loop is actually doing the PAUSE). Maybe why your sensor doesn't work that good. Now why better on PM than MPASM, I don't know.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

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


    Did you find this post helpful? Yes | No

    Default

    The new U2 programmer software version supports all the PIC16F193x. So, I was able to program my 16F1939 .

    Quote Originally Posted by mister_e View Post
    What kind of interrrupt it is? Remember that ON INTERRUPT will jump in your ISR ONLY after finishing a x current job. So if you have, say PAUSE 5000, in your main loop, it may take up to 5 secondes to jump in the ISR (assuming your main loop is actually doing the PAUSE).
    The interrupts that I'm using are kind of complicated (at least for me ). To make the Capacitive Sensors to work a value needs to be read from TMR1L and TMR1H together. This would tell you if the sensor was touched or not. However, the interrupt overflow is determined by TMR0. This is the way is done in the Application Notes. The interrupt settings for a 16F727 look something like this and it works,

    Code:
    OPTION_REG = %11000011       'Bit 2-0, 110= prescaler rate 1:16 (TMRO INTERRUPTS EVERY 1.024 mSec)
    T1CON = %11000101            'Timer1 initialization
    T1GCON = %11100001           'Timer1 gate init /Toggle Mode/TMR0 time base
    PIR1.7 = 0                   'Clear Gate Interrupt Flag. Timer1 gate is active (TMR1GIF BIT)
    PIE1.7 = 1                   'Disable the Timer1 Gate Acquisition complete interrupt (TMR1GIE BIT)
    
    TMR0 = 0			  'TMR0 overflows every (256-TMRO)*(Prescaler rate)(4*(1/16)uS)=1024uSec.
    
    ON INTERRUPT GOTO ISR
    INTCON = %10100000		'Enable Interrupts
    
    DISABLE			'Disable further interrupts
    ISR:    
        T1CON.0 = 0                 'Stop/Clears Timer1 before reading TMR1
    
    ....
    
    "Read TMRL and TMRH"
    
    ....
    
        TMR1L = 0               'Reset Timer1
        TMR1H = 0
        T1CON.0 = 1             'Restart/Enable Timer1 (TMR1ON BIT)
        TMR0 = 0                'RESET TMR0 TO 0 
        INTCON.2 = 0	          'Re-enable TMR0 interrupts. Bit 2, 0= clears overflow, 1= overflow ocurred 
    
        RESUME				    'Return to main program
        
        ENABLE				    'Enable interrupts
    "No one is completely worthless. They can always serve as a bad example."

    Anonymous

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


    Did you find this post helpful? Yes | No

    Default

    Byte_Butcher was working on Capacitive Touch on a 727 with DT_INTS here ...
    http://www.picbasic.co.uk/forum/show...1611#post71611

    I'm not sure what needs to be changed for the 1939, but it's probably a good start.

    DT

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


    Did you find this post helpful? Yes | No

    Default

    Darrel,

    My program is working fine with the 16F727 and the 16F1939 as it is. But, I think it will run a lot smoother if I use the DT interrupts .

    The amount of time that the chip takes between ISRs is very critical for the CSM (Capacitive Sensing Module) to work properly. So, please excuse my next dumb question . Can I say that I have a much better control of the interrupt intervals using DT interrupts than using ON INTERRUPT? And why?

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

    Anonymous

  5. #5
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    ON INTERRUPT will take care of the interrupt when it has time. A flag is set when the interrupt happens and is executed between instructions. If you have a long PAUSE the interrupt will not be serviced until the PAUSE is finished.

    ASM interrupts will take care of the interrupt immediately. Everything the chip is doing at the moment has to be saved then returned to. And the ISR is coded in ASM.

    Read the interrupt section in the back of the manual.

    DT's instant interrupts will make even a PBP type work like an ASM type.
    Dave
    Always wear safety glasses while programming.

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mackrackit View Post
    ON INTERRUPT will take care of the interrupt when it has time. A flag is set when the interrupt happens and is executed between instructions. If you have a long PAUSE the interrupt will not be serviced until the PAUSE is finished.

    ASM interrupts will take care of the interrupt immediately. Everything the chip is doing at the moment has to be saved then returned to. And the ISR is coded in ASM.

    Read the interrupt section in the back of the manual.

    DT's instant interrupts will make even a PBP type work like an ASM type.
    Dave,

    Thank you. Your answer was really helpful. I have a lot of reading to do to understand better how these different interrupts work.

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

    Anonymous

Members who have read this thread : 0

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

Posting Permissions

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