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

Truncated match.
PICList Thread
'why??'
1996\10\29@101827 by Clewer,Brian

flavicon
face
Hi folks;
    I am new to pics so please forgive me!!
Can anyone tell me why my first program does not work?
The processor is a 16c84.

pc   equ  0h
fsr  equ  2h
porta     equ  5h
portb     equ  6h
trisa     equ  85h
trisb     equ  86h
status    equ  3h
rp0  equ  5h


org  0

main:
    call init_portb          ; Initialisation of port
    call led_output     ; Output to leds
    goto main


init_portb:
    clrf portb          ;Initialise port by setting output latches
    bsf  status, rp0    ;select bank one
    movlw     0x00      ;value used to init port
    movwf     trisb          ;set port b to all outputs
return



led_output:
    movlw     0xAA
    movwf     portb
return





That's it !

All I want it to do is to switch on some led's but when it tries to output
to the port, it seems to alter the trisb!!

Please help

1996\10\29@104738 by liebchen

flavicon
face
Clewer,Brian wrote:
>
> Please help

You should select register bank 0 before you try
to access portb.

Wolfram

--

+------------------------------------------------+
! Wolfram Liebchen, Forschungsinstitut fŸr Optik !
! spam_OUTliebchenTakeThisOuTspamffo.fgan.de                    !
+------------------------------------------------+

1996\10\29@105218 by fastfwd

face
flavicon
face
Clewer,Brian <.....PICLISTKILLspamspam@spam@MITVMA.MIT.EDU> wrote:

> Can anyone tell me why my first program does not work?
> The processor is a 16c84.
>
> ....
>
> init_portb:
>      clrf  portb
>      bsf   status, rp0
>      movlw 0x00
>      movwf trisb
>      return

Brian:

You need a "BCF STATUS, RP0" after the "MOVWF TRISB".  Everything
will work fine after you add it.

-Andy

Andrew Warren - fastfwdspamKILLspamix.netcom.com
Fast Forward Engineering, Vista, California
http://www.geocities.com/SiliconValley/2499

1996\10\29@112942 by myke predko

flavicon
face
Brian,

When you changed your access to Bank 1 to change the TRISB register, you
didn't change back to Bank 0.  See the code below, I've added the missing line.

What are you using to develop the code?  I highly recommend using MPLAB, or
at least MPASM and MPSIM.  I *never* burn a PIC (even 16C84) without
simulating it six ways to Sunday (too much chance of a problem).  Download
MPSIM and it's manuals, print the manuals out and give it a shot.  If you
don't simulate, you'll just end up with a PIC that's sitting there and you
don't know what's going on.

myke
{Quote hidden}

     bcf       status, rp0     ;  Return to Bank 0 for Access
>return
                       ;  Will the "return" line on the first column be
                       ;  seen as a label?
{Quote hidden}

Avoiding precedents does not mean nothing should ever be done.  It only
means that nothing should ever be done for the first time - Sir Humphrey
Appleby K.C.B.

1996\10\29@112948 by Byron A Jeff

face picon face
>
> Hi folks;
>      I am new to pics so please forgive me!!
> Can anyone tell me why my first program does not work?

Because port TRISB is in the upper register bank and you never set it back to
bank 0 after setting trisb. Thee options:

1) Set the bank register bit to 1 (this is bit 5 of the status register RP0)
You did this. but you didn't set it back to zero afterwards...
2) Put the address of the TRIS register into FSR and access via indirect.
3) Use the TRIS instruction.

In fact this very reason was the sole purpose of the TRIS instruction, so
you don't have to bank switch to do the tris stuff.

BAJ
{Quote hidden}

1996\10\30@003150 by tjaart

flavicon
face
Clewer,Brian wrote:
{Quote hidden}

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
||||||||||||||||||||||||||||||||||||||||||||||||||||
{Quote hidden}

You didn't return to PAGE 0 after  setting up the direction.
Look in the init_portb: routine
--
Friendly Regards

Tjaart van der Walt
______________________________________________________________
|  Another sun-deprived R&D Engineer slaving away in a dungeon |
|WASP International GSM vehicle tracking and datacomm solutions|
|           +27-(0)11-622-8686 | http://wasp.co.za             |
|______________________________________________________________|

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