### Network

Jul 24, 2021
1
Hi everyone,

movlw 0x9D
movlw 0x08
wait
bra wait

#### Harald Kapp

##### Moderator
Moderator
Nov 17, 2011
12,612
RTFM
The solution is in the header of the code you linked to:
Code:
; These are the psuedo "registers" used by the 16 BIT operations
;
_REG_A       EQU     H'007E'
_REG_B       EQU     H'007C'
Obviously the 16 bit numbers are stored in
_REG_A which is made of 2 × 8 bit memory locations located at 0x007E and 0x007F and
_REG_B which is made of 2 × 8 bit memory locations located at 0x007C and 0x007D.

Code:
; This include file provides some macros for dealing with
; 16 bit quantities. It assumes a little endian format
; where the least significant byte is lower in address than
; the most significant byte.
It seems all you have to do is put the LSB and MSB from the ADC (ADRESL and ADRESH) into these memory locations and call the macro for shifting. Since the macro does a shift by 1, you have to call it twice to shift the 12 bit number by 2 positions yo get the 10 bit number you need.

I'm not familiar with PICs and MPLAB so that is all the advice I can give.

#### hevans1944

##### Hop - AC8NS
Jun 21, 2012
4,739
I'm not familiar with PICs and MPLAB so that is all the advice I can give.
Your first statement in post #2: RTFM is the key to using any PIC... well, successfully using any sufficiently advanced technology, actually, unless you happen to be a real magician. Read The Fine Manual!

As I have said before, Microchip always somehow manages to stuff ten pounds of "stuff" into a one-pound package. If you need to use most or all of the functionality a given PIC provides, this can save time and simplify or eliminate the need for some support circuity during the initial design process. But if you need to use just a subset of the available functionality, then you must also know how to disable or ignore the functionality you don't use. It is absolutely critical that you download, read and understand the complete datasheet for the PIC you plan to use. This is true for any microprocessor of course, but I have found it is especially true for Microchip PIC microprocessors.

RTFM... more than once! You are sure to miss, or misinterpret, something important the first time through. It helps me if I print out a hard copy of the datasheet and keep it handy while I design and write the application program that will be downloaded into the PIC.

Replies
1
Views
3K
Replies
1
Views
1K
Replies
6
Views
2K
B
Replies
26
Views
3K
B
M
Replies
14
Views
4K
Joerg
J