Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

xorfw instruction doesn't work

Status
Not open for further replies.

newbie111

Member level 2
Joined
Nov 29, 2009
Messages
51
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Location
h.k
Activity points
1,609
Hi,

I am learning how to use the xorfw instruction from this site

https://www.hobbyprojects.com/pic_tutorials/tutorial7.html

everything was ok until i came to tutorial7


i complied the following codes from this lesson but
hmmmm my portC,1 LED stayed on no blinking at all

I wonder why

Code:
  #include <p16F690.inc>
    __config (_INTRC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_OFF & _MCLRE_OFF & _CP_OFF & _BOR_OFF & _IESO_OFF & _FCMEN_OFF)



cblock 0x20
COUNT1                   ; Define two file registers for the
COUNT2 
           ; delay loops

endc

org  0

 bsf                  STATUS,RP0   ;Switch to Bank 1
                        movlw              0x00              ;Set the Port c pins
                        movwf              TRISC            ;to output.

                        
 bcf                   STATUS,RP0 ;Switch back to Bank 0 
    movlw              0x02  

        
Start           xorwf               PORTC,1

       call Delay     

                                                                                                                            ;255 to zero, 255 times

         goto  Start

Delay

Loop1            decfsz               COUNT1,1      ;This second loop keeps the LED
                    goto                 Loop1            ;turned off long enough for us to
                    decfsz               COUNT2,1      ;see it turned off
                    goto                  Loop1              ;
                     return

                 end



Would anyone kindly tell me what's wrong?

lol Gosh I have been trying this for 3 hours so far.


Thanks a lot[/code]
 

It's difficult to tell without more information but I can give this advice to try:

1. The interrupt vector for the '690 is at address 0x04 which is in the middle of your code. Any active interrupts will probably cause it to crash. The solution is to put an instruction at address 0x00 (immediately after your 'org 0') which says 'goto Begin'.
Then add another 'org' at address 0x05 followed by the label 'Begin'. This will prevent the assembler using the first few addresses where the interrupt vector resides from being used by your program.

2. I am not sure what clock speed you are using. The delay routine waits 256*256 loops (= 65536) and the execution speed is Fosc/4 so you are toggling the output pin at 1/262144 of the clock speed. At high clock speeds the flash may be too fast to see.

Brian.
 

    newbie111

    Points: 2
    Helpful Answer Positive Rating
Hi,


Hmmmm - only 3 hours !!!

The working code is attached, you needed to turn off the Analogue part of the ports using the ANSEL instruction ( not the adcon1 as I metioned before )

You can also use the Banksel instruction to make it easier to switch the banks.

ps your delay is 200ms so you will just see it flashing, call the delay twice each pass and the flash should be clearer
 

    newbie111

    Points: 2
    Helpful Answer Positive Rating
Thank you so much!

It worked well now. :)
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top