2020/11/12 08:57:42
ehoutman
How can you start the ADC in assembly? I use an .s file for the assembly code that works fine in itself.
In for instance PIC18 assembly one can use: "bsf    ADCON0, GO, ACCESS"
But if I try this with let's say: "bset    ADCON3L, CNVRTCH"  for the dsPIC33, I get an "Invalid operands specified ('bset.b ADCON3L,CNVRTCH')" error.
 
Whatever I try, I just can't figure out the right syntaxis
Please, put me on the right track
 
Thanks in advance
2020/11/12 09:20:27
1and0
ehoutman
But if I try this with let's say: "bset    ADCON3L, CNVRTCH"  for the dsPIC33, I get an "Invalid operands specified ('bset.b ADCON3L,CNVRTCH')" error.
 
Whatever I try, I just can't figure out the right syntaxis
Please, put me on the right track

Try
bset    ADCON3L, #CNVRTCH

2020/11/12 09:37:45
MBedder
1and0
Try
bset    ADCON3L, #CNVRTCH

Wrong. Should have written instead:

Try
RTFM
LoL
2020/11/14 10:02:31
ehoutman
Thanks 1and0, that's it.
Example 1-1 from the XC16 Assembler, Linker and Utilities User's Guide got me a bit.b confused.
2020/11/14 14:32:00
Gort2015
Something like this where a bit can set or cleared by BSW (Bit Write in W)
using the Zero or Carry Flags (Default Zero)
 
None of the instructions used below has an any affect on Z or C.
BSW [base], lock
 
[base] is the indirect word that will change
lock is the bit position.
 
   _
If Z = 0 it is the equivilent of bset [base], lock
 
   _
If Z = 1 it is the the equivilent of bclr [base], lock
 
; ----------------------------------------------------
; reserved      = w0
x               = w1
key             = w2
base            = w3
lock            = w4

pin_unlock:
    bset    SR, #Z
    bra     $+4
    ; - - - - - - - - - - - - - - - - - - -
pin_lock:
    bclr    SR, #Z
    ; - - - - - - - - - - - - - - - - - - -
    ; useful
    mov     #RPCON,  base
    mov     #IOLOCK, lock
    mov     #NVMKEY, key
    ; - - - - - - - - - - - - - - - - - - -
    ; key
    mov     #0x55, x
    mov.b   x, [key]
    mov     #0xAA, x
    mov.b    x, [key]
    ; - - - - - - - - - - - - - - - - - - -
    ; lock / un-lock
    bsw     [base], lock
    return
; ----------------------------------------------------

2020/11/16 03:27:40
ehoutman
Gort2015, I wonder if mob,b can be used to write let's say the channel number directly to the CNVCHSELn bits.in the ADCON3L register. This would save al lot of AND and OR instructions.
Our current project is extremely time sensitive. That's why.
2020/11/16 04:51:01
MBedder
RTFM says there is a BFINS instruction which does exactly what you want. RTFM is DS70000157G page 133.
2020/11/16 06:57:15
1and0
ehoutman
... This would save al lot of AND and OR instructions.
Our current project is extremely time sensitive. That's why.

Then you better familiar yourself with all the instructions in the "Instruction Set Summary" chapter of your PIC datasheet. For additional information, you should read the "16-Bit MCU and DSC Programmer's Reference Manual" too.
2020/11/17 03:00:00
ehoutman
Indeed, I overlooked this BFINS completely. Have a better look next time :(
2020/11/17 10:16:38
Gort2015
BFINS/BFEXT saves register use but takes two cycles to complete.
 
    ; 10 bit ID, write lower 8 bits, RW = 0
    bfext   #8, #8, [--SP], ID
    bra     i2c_writea
    ; - - - - - - - - - - - - - - - -
 
That instruction reads the high byte from the stack into ID, remaing bits are cleared.
12
© 2021 APG vNext Commercial Version 4.5

Use My Existing Forum Account