Inline Asm Problem


Results 1 to 7 of 7

Threaded View

  1. #1

    Default Inline Asm Problem

    Hello group,

    I am trying to get an adjustable delay routine that is less than 1us increaments i.e (pauseus). I use to program in assembly and had a working delay routine. It took three machine cycles to decrement the counter by one. Using
    a 40mhz it should have a 300ns resolution. It is adjustable by taking a adc reading in pbp and passing the variable to the inline assembly routine. When I compile it in PBP3 it produces some errors. Using a PIC18F25K80. If anyone knows why it won't compile or has an alternate idea, I would be greatful.

    Thanks
    Mark

    See screen capture of error messages
    Name:  error.pg.JPG
Views: 372
Size:  71.0 KB

    Code:
    ' Name  : Asm delay test
    'pic18f25k80  10mhz x 4pll 40mhz
    'pbp 3.07
    'CONFIGS sec osc set to digital i/o,intoscio off, hs-pll on,SECONDARY OSC OFF, ext intructions off
    'configs set in melabs u2 programmer
    '------------------------------------------------------
    DEFINE OSC 40    '64mhz
    
    REFOCON = 0          'Ref osc off
    '--------------------------------------------------    
    ODCON = 0          '   OPEN DRAIN OFF , CONNECTED TO VDD
    'ADC-----------------------------------------------------		    
    ADCON0 = %00000101 ' A/D module enabled, channel 1
    ADCON1 = %01110000 '%01110000 Vref = INT 4096, TRIG ctmu, NEG REF VSS
    ADCON2 = %10010100 ' Right justified, 12 Tad, Frc clock
    ANCON1 = %00000000  'Select Digital or Analog AN8 - AN14
    SLRCON = 0 'SLEW RATE STANDARD
    '-------------------------------------------------------------
    'COMPARATOR      '*********SET TRIS INPUTS
    CM1CON = 0 '%11000000    'COMPARATOR 1 on all pins external
    CM2CON = 0 '%11000000    'COMPARATOR 2 on all pins external              
    CVRCON = %00100111    'COMPARATOR vref off
    '--------------------------------------------
    CTMUCONH = 0  'Charge time measurement unit off
    'MSSP-------------------------------------------
    SSPSTAT = %00000000   'TX IDLE LOW,SAMPLE MIDDLE
    SSPCON1 = 0'%00100001 ' ENABLE MSSP,CLK IDLE LOW,FOSC/4
    '-----------------------------------------------------------------------
    TRISA = %00000111
    TRISB = %00000000
    TRISC = %00010000
    
    AUX1 VAR LATC.0  ' output
    Delay1 var word 
    Temp1  var word
    adc_an1 var word
    
    
    '-------------------------------------------
    mainloop:
    
    gosub get_adc 
    
    LATC.0 = 1 'Portc.0 High
    
    ; Delay routine 3 cycles for each count. Number of loops = adc read
    ; at 40mhz delay should have 300ns resolution
    ASM      
       movfw  _Delay1
       movwf  _Temp1
       decfsz _Temp1,1
       goto   $-1
    Endasm
    LATC.0 = 0 'Portc.0 Low
    
    pauseus 500
    
       Goto mainloop
    '------------------------------------------      
    get_adc:  '12bit
       ADCON0 = %00000111  'SAMPLE AN1 
                       '
     WHILE ADCON0.1 = 1  'WAIT FOR CONVERSION
        WEND
         ADC_AN1.HIGHBYTE = ADRESH
         ADC_AN1.LOWBYTE  = ADRESL
            DELAY1 = 1 + adc_an1  '1 to 4097
    Return
       End
    Last edited by mark_s; - 26th February 2016 at 19:59.

Similar Threads

  1. ASM - Problem at first step!
    By Megahertz in forum Off Topic
    Replies: 13
    Last Post: - 27th July 2011, 00:43
  2. Problem with -ASM
    By Megahertz in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 8th May 2011, 16:29
  3. Problem using ASM instruction
    By ewandeur in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 3rd April 2008, 15:26
  4. LCD 16 characters inline: only first 8 work
    By Mugel in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 20th October 2006, 22:07
  5. problem with asm interrupt
    By servo260 in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 20th December 2004, 17:02

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