Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

BoostC Macro Help

Status
Not open for further replies.

Mike - K8LH

Well-Known Member
I'm struggling trying to get a cycle accurate fixed/constant delay macro running in BoostC. Here's what I'm trying to duplicate;

Code:
clock   equ     8               ; 4, 8, 12, 16, 20 MHz, etc.
usecs   equ     clock/4         ; cycles per usec multiplier
tStep   equ     1*usecs         ; cycles per BAM step (1T)
;
;  in-line fixed delay macro, 0..1027 cycles, 14 bit core
;
inDlyCy macro   delay           ; generates 0 to 6 instructions
        local   loop
     if delay > 3
        movlw   delay/4-1       ;
loop    addlw   -1              ; borrow?  (4 cycle loop)
        bc      loop            ; no, branch, else, fall thru'
     endif
     if delay%4 >= 2
        goto    $+1             ; delay%4 == 2 or delay%4 == 3
     endif
     if delay%4 & 1
        nop                     ; delay%4 == 1 or delay%4 == 3
     endif
        endm
And here's how I'd like to be able to use it in a BoostC program;
Code:
/**********************************************
 *  1-usec BAM step size (1T)                 *
 **********************************************/

void interrupt()
{ pir1.TMR2IF = 0;       // clear Timer 2 interrupt flag
  porta = colsel;        // select new column
  portb = bdat[0];       // 2^0 (1T) data
  inDlyCy(1*tstep-2);    // 2^0 (1T) delay
  portb = bdat[1];       // 2^1 (2T) data
  inDlyCy(2*tstep-2);    // 2^1 (2T) delay
  portb = bdat[2];       // 2^2 (4T) data
  inDlyCy(4*tstep-2);    // 2^2 (4T) delay
  portb = bdat[3];       // 2^3 (8T) data
  inDlyCy(8*tstep-2);    // 2^3 (8T) delay
  ...
}
I would just code the delays as in-line assembly but the BoostC compiler doesn't support assembler expression evaluation such as movlw (8*tstep)/4-1-2.

I appreciate any help guys.

Regards, Mike
 
Last edited:
Status
Not open for further replies.

Latest threads

Back
Top