Searching \ for 'headache' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: techref.massmind.org/techref/index.htm?key=headache
Search entire site for: 'headache'.

Truncated match.
PICList Thread
'headache'
1998\11\25@233841 by KHOO YEOW KWANG

flavicon
face
Hello all, I'm a student doing my final year project using the pic chip, as
I never learn how to do programming the PIC b4, hope u all don't mind
helping me out with this.


I modified these codes but i wasn't sure what it can do, especially the
equation of the ports that part.
BTW, i'm using a PIC16C73 chip & the MPLAB, one more thing is that when i do
a <debug>, <run> & <step>, the checking will be stucked when a looping
occurs... can anybody help me

;====================p98069.asm============25/11/98===============
;THIS PROGRAM SENDS THE VALUE SERIALLY VIA THE MAX232 AT 1200BPS
;PORTA IS THE I/P PORT THAT IS CONNECTED TO THE THERMISTER
;PORTC IS CONNECTED TO THE MAX232
;PORTC  RC7/RX  RC6/TX
;               R1/OUT          T1/IN
;-----------------------------------------------------------------
               LIST    P=16C73
               RADIX   R=HEX
;-----------------------------------------------------------------

PORTA           EQU     05H     ;PORTA
PORTC           EQU     07H     ;PORTC
TRISA           EQU     85H     ;TRISA REGISTER
TRISC           EQU     87H     ;TRISC REGISTER
TMR2            EQU     11H     ;TIMER2 REGISTER
INTCON          EQU     8BH     ;
STATUS  EQU     03H     ;STATUS REGISTER
ADCON0  EQU     1FH     ;
ADCON1  EQU     9FH     ;

TX              EQU     0
TOIF            EQU     1
RP0             EQU     1
W               EQU     1
F               EQU     1
RX              EQU     1

COUNT           EQU     0X0E
CNT_LOW EQU     0X10    ;DELAY COUNTERS
CNT_MID EQU     0X11
CNT_HIGH        EQU     0X12
TEMP            EQU     0X0F
RXDATA  EQU     0X0C
TXDATA  EQU     0X0D



;---------------------------------------------------------------

       ORG     0
       GOTO    START
       ORG     4
       RETFIE

;---------------------------------------------------------------

START   BSF             PORTC,TX        ;MAKE SURE SERIAL O/P IS HIGH
       BSF             STATUS,RP0
       MOVLW   B'11111111'     ;ALL I/P ON PORTA FROM DATA PORT/ANALOG
       MOVWF   TRISA
       MOVLW   B'10000000'     ;RC7 IS SET AS ANALOG I/P
       MOVLW   TRISC           ;RC6 IS SET AS O/P

;---------------------------------------------------------------
;ANALOGUE TO DIGITAL CONVERSION
;---------------------------------------------------------------

       MOVLW   B'11000001'     ;7,6,0    ARE SET AS I/P
       MOVWF   ADCON0
       BSF             STATUS,RP0      ;RA0 & RA1 ARE ANALOG I/P
       MOVLW   B'00000100'
       MOVWF   ADCON1
       BCF             STATUS,RP0
       BSF             ADCON0,2        ;SET GO/DONE BIT
LOOP1   BTFSC           ADCON0,2
       GOTO            LOOP1
       MOVF            PORTC,TX
       BSF             PORTC,W
       CALL            TXBYTE          ;TRAMSMITT THIS BYTE
       CALL            ONESEC          ;WAIT ONE SEC

;----------------------------------------------------------------
;TRANSMIT 1 BYTE IN W AT 1200BPS
;----------------------------------------------------------------

TXBYTE  MOVWF   TXDATA  ;SAVE IN REGISTER
               BSF             PORTC,TX        ;MAKE SURE TX IS HIGH
               MOVLW   .8
               MOVWF   COUNT
               BCF             PORTC,TX
               CALL            DELAY

TXLOOP  RRF     TXDATA,1        ;ROTATE NEXT    BIT
               BTFSC   STATUS,RX
               GOTO    TXHIGH
               BCF     PORTC,TX

TX1             CALL    DELAY
               RETURN

TXHIGH          BSF     PORTC,TX
               GOTO    TX1

;----------------------------------------------------------------
;DELAY ADJUSTED FOR 1200BPS RATE
;----------------------------------------------------------------

DELAY   BCF             INTCON,TOIF
       MOVLW   .204            ;52*(1/(1000000/16))=.000833SEC=(A/1200) OR
1200 BAUD
       MOVWF   TMR2
       BTFSS           INTCON,TOIF
       GOTO            $-1
       RETURN

;---------------------------------------------------------------
;DELAY FOR ABOUT 1 SECOND BASED ON 4MHZ CLOCK CYCLE
;---------------------------------------------------------------

ONESEC  MOVLW   0X04
               MOVWF   CNT_HIGH
               CLRF            CNT_MID
               CLRF            CNT_LOW
DELAY1  NOP
               DECFSZ  CNT_LOW,1
               GOTO            DELAY1
               DECFSZ  CNT_MID,1
               GOTO            DELAY1
               DECFSZ  CNT_HIGH,1
               GOTO            DELAY1
               RETURN

;----------------------------------------------------------------
       END
;================================================================

1998\11\26@021020 by engelec

picon face
KHOO YEOW KWANG wrote:

> occurs... can anybody help me
>

sure why not
I think for beginner 73 will be difficult to learn
the best pic for learning is 84


{Quote hidden}

is correct, you can use include file instead why bother typing all this

> TX              EQU     0
> TOIF            EQU     1
> RP0             EQU     1
> W               EQU     1
>

w should be 0

> F               EQU     1
> RX              EQU     1
>
> COUNT           EQU     0X0E
>

your RAM locations start at 0x20 it will lock up the processor.

> CNT_LOW EQU     0X10    ;DELAY COUNTERS
> CNT_MID EQU     0X11
> CNT_HIGH        EQU     0X12
> TEMP            EQU     0X0F
> RXDATA  EQU     0X0C
> TXDATA  EQU     0X0D
>

above 6 lines are wrong it should be 0x20,0x21 and upor you can use CBLOCK like
this

       cblock    0x20
       label1
       label2
       more labels
       endc

{Quote hidden}

before initializing ports this line wouldn't doany thing you have to do it after
setting up the port


{Quote hidden}

up to here is fine

>         MOVLW   B'11000001'     ;7,6,0    ARE SET AS I/P
>         MOVWF   ADCON0
>

adcon0 is in bank 0 you need to switch back to bank 0otherwise it wouldn't do
any thing for you

>         BSF             STATUS,RP0      ;RA0 & RA1 ARE ANALOG I/P
>

you are in bank 1 already

>

>         MOVLW   B'00000100'
>         MOVWF   ADCON1
>

>         BCF             STATUS,RP0
>

you need to put delay here to charge the cap

>         BSF             ADCON0,2        ;SET GO/DONE BIT
> LOOP1   BTFSC           ADCON0,2
>         GOTO            LOOP1
>

you just started conversion but you didn't doany thing with result register.


>         MOVF            PORTC,TX
>

since you have TX equ 0 it will load portc in to Wsame as this
       MOVF        PORTC,W
I do not think this is what you ware tying to do


>         BSF             PORTC,W
>

this line tells me that you are not familiar with W register.you have w  equ  1
it will set RC1 on
I do not think this is what you ware tying to do

sorry I have to go I will continue later if I can.
read more about W register.

Andre Abelian


{Quote hidden}

1998\11\26@024348 by Dr. Imre Bartfai

flavicon
face
Hi,

I will insert my comments below.

On Thu, 26 Nov 1998, KHOO YEOW KWANG wrote:

{Quote hidden}

; Obviously, you forgot here to switch to Bank #0.
       BCF     STATUS,RP0

{Quote hidden}

; The syntax and the meaning of the two statements above are completely
; fouled up.
; The 2nd operand of MOVF should be either 1 (=F), or 0 (=W).
; The 2nd operand of BSF is a bit index (0..7)

{Quote hidden}

; The code above is rather a "spaghetti code". It 'd be better to set up
; program structure as it would be an "if ... then ... else".
; I do not see any loop here (DECFSZ COUNT)

>
> ;----------------------------------------------------------------
> ;DELAY ADJUSTED FOR 1200BPS RATE
> ;----------------------------------------------------------------
>
> DELAY   BCF             INTCON,TOIF
>         MOVLW   .204            ;52*(1/(1000000/16))=.000833SEC=(A/1200) OR
> 1200 BAUD

; where did you get from that value 16?

{Quote hidden}

I hope this helps.

Imre


'headache'
1998\12\01@035157 by KHOO YEOW KWANG
flavicon
face
How to set rp0 to bank0??
i have played with the codes a couple of times but yet i still get these
msgs error....

my program is below the build

Building P98069.HEX...

Compiling P98069.ASM:
Command line: "C:\p98069\MPLAB\MPASMWIN.EXE /e+ /l+ /x- /w0 /c+ /m+ /rhex
/p16C73 /q C:\P98069\MPLAB\P98069.ASM"
Warning[216] C:\P98069\MPLAB\P98069.ASM 9 : Radix superceded by command
line.
Message[302] C:\P98069\MPLAB\P98069.ASM 62 : Register in operand not in bank
0.  Ensure that bank bits are correct.
Message[302] C:\P98069\MPLAB\P98069.ASM 75 : Register in operand not in bank
0.  Ensure that bank bits are correct.
Message[302] C:\P98069\MPLAB\P98069.ASM 76 : Register in operand not in bank
0.  Ensure that bank bits are correct.
Message[302] C:\P98069\MPLAB\P98069.ASM 81 : Register in operand not in bank
0.  Ensure that bank bits are correct.
Message[302] C:\P98069\MPLAB\P98069.ASM 82 : Register in operand not in bank
0.  Ensure that bank bits are correct.
Message[302] C:\P98069\MPLAB\P98069.ASM 134 : Register in operand not in
bank 0.  Ensure that bank bits are correct.
Message[302] C:\P98069\MPLAB\P98069.ASM 137 : Register in operand not in
bank 0.  Ensure that bank bits are correct.

Build completed successfully.

----------------------------------------------------------------------------
----------------------------------------------------------------------------
----------------------------------

;====================p98069.asm============25/11/98===============
;THIS PROGRAM SENDS THE VALUE SERIALLY VIA THE MAX232 AT 1200BPS
;PORTA IS THE I/P PORT THAT IS CONNECTED TO THE THERMISTER
;PORTC IS CONNECTED TO THE MAX232
;PORTC  RC7/RX  RC6/TX
;       R1/OUT  T1/IN
;-----------------------------------------------------------------
               LIST    P=16C73
               RADIX   HEX
;-----------------------------------------------------------------

PORTA           EQU     05H     ;PORTA
PORTC           EQU     07H     ;PORTC
TRISA           EQU     85H     ;
TRISC           EQU     87H     ;
TMR2            EQU     11H     ;TIMER2 MODULE'S REGISTER
INTCON          EQU     8BH     ;INTERRUPT CONTROL REGISTER
STATUS  EQU     03H     ;STATUS REGISTER
ADCON0  EQU     1FH     ;SELECTS CLOCK, CHANNEL, ON/OFF AND GO/DONE
ADCON1  EQU     9FH     ;SELECTS THE NUMBER OF ANALOGUE CHANNELS
ADRES           EQU     1EH     ;RESULTING REGISTER
PIE1            EQU     8CH     ;
PIR1            EQU     0CH     ;

TX              EQU     0       ;TX IS HIGH
TOIF            EQU     2       ;TOIF IS BIT 2
RP0             EQU     5       ;
W               EQU     0       ;REGISTER W = 0
F               EQU     1       ;REGISTER F = 1
RX              EQU     1
PEIE            EQU     6
GIE             EQU     7
ADIE            EQU     1
ADIF            EQU     1


COUNT           EQU     0X20
CNT_LOW EQU     0X21    ;DELAY COUNTERS
CNT_MID EQU     0X22
CNT_HIGH        EQU     0X23
TEMP            EQU     0X24
RXDATA  EQU     0X25
TXDATA  EQU     0X26



;---------------------------------------------------------------

       ORG     0
       GOTO    START
       ORG     4
       RETFIE

;---------------------------------------------------------------
;PORT INITIALISATION
;---------------------------------------------------------------

START   BSF             STATUS,RP0      ;SELECT REGISTER BANK0
       MOVLW   B'10000000'     ;RC7 IS SET AS ANALOG I/P
       MOVLW   TRISC           ;RC0 TO RC6 ARE SET AS O/P
       MOVLW   B'11111111'     ;ALL I/P ON PORTA FROM DATA PORT/ANALOG
       MOVWF   TRISA           ;SET ALL AS INPUTS

       BCF             STATUS,RP0      ;SELECT REGISTER BANK1
       CLRF            PORTC           ;ENSURE PORTC IS CLEAR
       CLRF            PORTA           ;ENSURE PORTA IS CLEAR



;---------------------------------------------------------------
;ANALOGUE TO DIGITAL CONVERSION
;---------------------------------------------------------------

       BSF             STATUS,RP0      ;SELECT BANK 1
       CLRF            ADCON1          ;CONFIGURE A/D INPUTS
       BSF             PIE1,ADIE       ;ENABLE A/D INTERRUPTS
       BCF             STATUS,RP0      ;SELECT BANK0
       MOVLW   B'11000001'     ;BITS 7,6,0 ARE SET AS I/P
       MOVWF   ADCON0          ;DO IT
       BCF             PIR1,ADIF       ;CLEAR A/D INTERRUPT FLAG BITS
       BSF             INTCON,PEIE     ;ENABLE PERIPHERAL INTERRUPTS
       BSF             INTCON,GIE      ;ENABLE ALL INTERRUPTS
       BSF             STATUS,RP0      ;RA1 IS ANALOG I/P

WRMSTT  GOTO    $+1             ;2uS DELAY
               GOTO    $+1             ;2uS DELAY
               GOTO    $+1             ;2uS DELAY
               GOTO    $+1             ;2uS DELAY
               GOTO    $+1             ;2uS DELAY
               NOP
               NOP
               CLRWDT

               BSF     ADCON0,2        ;SET GO/DONE BIT TO START A
CONVERSION
LOOP1           BTFSC   ADCON0,2        ;TEST BIT 2 IN FILE F,
                                       ;SKIP THE NEXT INSTRUCTION WHEN IT'S
LOGIC 0,
                                       ;THEN DO THE NEXT INSTRUCTION
       GOTO    LOOP1                   ;
       MOVF    ADRES,W         ;THIS IS WHERE THE RESULTS BEING HELD
       MOVWF   PORTC           ;GET THE CONVERTED VALUE FROM F
       GOTO    WRMSTT          ;LOOP BACK TO REAQUIRE THE NEXT SAMPLE

       BSF     PORTC,W         ;SELECT THE CONVERTED VALUE TO TRANSMIT
       CALL    TXBYTE          ;TRAMSMITT THIS BYTE
       CALL    ONESEC          ;WAIT ONE SEC

;----------------------------------------------------------------
;TRANSMIT 1 BYTE IN W AT 1200BPS
;----------------------------------------------------------------

TXBYTE  MOVWF   TXDATA  ;SAVE IN REGISTER
               BSF     PORTC,TX                ;MAKE SURE TX IS HIGH
               MOVLW   .8              ;
               MOVWF   COUNT           ;
               BCF     PORTC,TX                ;
               CALL    DELAY                   ;
               DECFSZ  COUNT,1 ;

TXLOOP  RRF     TXDATA,1                ;ROTATE NEXT BIT
               BTFSC   STATUS,RX               ;
               GOTO    TXHIGH                  ;
               BCF     PORTC,TX                ;

TX1             CALL    DELAY                   ;
               RETURN                  ;

TXHIGH          BSF     PORTC,TX                ;
               GOTO    TX1                     ;

;----------------------------------------------------------------
;DELAY ADJUSTED FOR 1200BPS RATE
;----------------------------------------------------------------

DELAY   BCF     INTCON,TOIF             ;
       MOVLW   .204            ;52*(1/(1000000/16))=.000833SEC=(A/1200) OR
1200 BAUD
       MOVWF   TMR2            ;
       BTFSS   INTCON,TOIF             ;
       GOTO    $-1                     ;
       RETURN                  ;

;---------------------------------------------------------------
;DELAY FOR ABOUT 1 SECOND BASED ON 4MHZ CLOCK CYCLE
;---------------------------------------------------------------

ONESEC  MOVLW   0X04            ;
               MOVWF   CNT_HIGH        ;
               CLRF            CNT_MID ;
               CLRF            CNT_LOW ;
DELAY1  NOP                             ;
               DECFSZ  CNT_LOW,1       ;
               GOTO            DELAY1  ;
               DECFSZ  CNT_MID,1       ;
               GOTO            DELAY1  ;
               DECFSZ  CNT_HIGH,1      ;
               GOTO            DELAY1  ;
               RETURN                  ;

;----------------------------------------------------------------
       END
;================================================================

{Quote hidden}

1998\12\01@061807 by

flavicon
face
They are not errors, just a message to let you know that you are performing
and operation on a register that is not in bank 0.

MPASM dosen't know what the currectly selected bank is, it's up to you to
ensure they are correct.

The fact that MPASM reports "Build completed successfully" means that there
were no actual errors.

Mike Rigby-Jones
mrjonespamKILLspamnortelnetworks.com

{Quote hidden}

<big, big snip>

1998\12\01@071755 by Stefan Sczekalla-Waldschmidt

flavicon
face
Hi,

KHOO YEOW KWANG wrote:
>
> How to set rp0 to bank0??
> i have played with the codes a couple of times but yet i still get these
> msgs error....


It4s just a Warning, if you are SURE RP0 and RP1 are set correctely you
can
ignore this message. Same with the RADIX, keep also SURE that the
correct way of
expressing numbers was choosed. because "10" may be interpreted as 10
decimal
or 10 hex. SO better doe D'10' for decimal, and 0x10 for hex. More can
be found in
the mpasm-docu

Kind regards

       Stefan

1998\12\01@114727 by andre

flavicon
face
Rigby-Jones, Michael [PAI01:4837:EXCH] wrote:

> They are not errors, just a message to let you know that you are performing
> and operation on a register that is not in bank 0.
>

yes sure there no error but portc wouldn't work .

Andre


{Quote hidden}

1998\12\01@134413 by PIC List

flavicon
face
It is also possible to set the level of messages you receive when compiling
to either All Messages, Warnings and Errors, or Just Errors. You'll find
this in the Node Properties when you chose Project, and then Edit Project.



{Quote hidden}

More... (looser matching)
- Last day of these posts
- In 1998 , 1999 only
- Today
- New search...