![]() | ![]() | ![]() |
| | |||||||
| Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc. |
| | Thread Tools | Display Modes |
| | (permalink) |
| Experienced Member | I have successfuly programmed LED flashing programme with those normal codes (MOV and all that..) now, I'm trying this XOR one but, don't understand why this is not working. Code: list p=16f690 #include<p16f690.inc> #define LED PORTC,0;Define pin 0 of port c as LED __CONFIG _MCLRE_ON & _CP_OFF & _WDT_OFF & _INTRC_OSC_NOCLKOUT ERRORLEVEL -302 TEMP_VAR UDATA temp RES 1 delay1 RES 1;reserves 1 byte for delay1 delay2 RES 1;reserves 1 byte for delay2 ;******************************************************************* Main:;Main programme begains CODE 0x05; Start address at 0x05 Setpins:; Select output and input bsf STATUS,RP0 ;Switch to bank 1 movlw b'11110';MOVe 11110 to W movwf TRISC ;set pin 0 of PORT C as output bcf STATUS,RP0 ;Switch back to bank 0 movlw b'00001';MOVe 00001 to W Start: xorwf LED call Loop call Loop goto Start Loop: decfsz delay1,1 goto Loop decfsz delay2,1 goto Loop return END |
| | |
| | (permalink) |
| Super Moderator | How about specifing a destination for the XORWF instruction?. |
| | |
| | (permalink) |
| Experienced Member | hi, I cannot see that LED has been declared.? xorwf LED You pipped me again Nigel, I must be getting slower... I'll opt out of this one.
__________________ Eric "Good enough is Perfect" PIC tutorials: Gramo's: www.digital-diy.net/ Bill's: www.blueroomelectronics.com/ |
| | |
| | (permalink) |
| Experienced Member | I tried what Gayan Soyza suggested but, that is not working and I am already using Nigel's tutorials they are very helpful but, I can't see any special help on XOR, please help me, I'm on this for hours, trying to blink just an LED with XOR code !, please point out where is the mistake I'm just a layman! |
| | |
| | (permalink) |
| Experienced Member | At the top of your code you use the following Code: #define LED PORTC,0;Define pin 0 of port c as LED Code: xorwf LED Code: xorwf PORTC,0 What you want is Code: xorwf PORTC, F |
| | |
| | (permalink) |
| Experienced Member | Also, you need to turn off analogue mode and set the port to digital I/O. See datasheet Code:
Setpins:; Select output and input
bsf STATUS,RP0 ;Switch to bank 1
movlw b'11110' ;MOVe 11110 to W
movwf TRISC ;set pin 0 of PORT C as output
bcf STATUS, RP0 ; Switch to bank 2
bsf STATUS, RP1
bcf ANSEL, ANS4 ; Set PORTC, 0 to digital mode
bcf STATUS,RP0 ;Switch back to bank 0
bcf STATUS,RP1
movlw b'00001' ;MOVe 00001 to W
Start:
xorwf PORTC,F
call Loop
call Loop
goto Start
Loop:
decfsz delay1,1
goto Loop
decfsz delay2,1
goto Loop
return |
| | |
| | (permalink) |
| Experienced Member | Hmm....... that works bcf ANSEL,ANS4 and why not,: bcf ANSEL,ANS0 After all the LED is connected at pin 0 of port c and not at pin 4 I mean the data sheet says : Setting the ANSx bit of a corresponding pin will cause all digital reads of that pin to return ‘0’ and also permit analog functions of that pin to operate correctly. Please explain as easily as possible, Thank you for your help !! |
| | |
| | (permalink) | |
| Experienced Member | Quote:
| |
| | |
| | (permalink) |
| Experienced Member | I'm sorry but I still don't get that, I know this may sound stupid to you but I'm working with .ASM since last few days only, I have checked all registers associated with port c (that is given in table format in datasheet) and I found that ANS4 is corresponds to bit 4 and bit 4 also corresponds to pin 4 of port c, I know you are trying to tell me something quite different but, if you can make it more simpler than I'll be very grateful ! |
| | |
| | (permalink) | |
| Experienced Member | Quote:
AN0 thru AN7 are set in the ANSEL register and AN8 thru AN11 in ANSELH. If for example you want to use port RB4 as digital I/O you would clear ANS10 bit in ANSELH register. | |
| | |
| | (permalink) |
| Experienced Member | Oh! |
| | |
| | (permalink) |
| Experienced Member | To save memory they pack lots of sometimes unrelated bits into a single register. |
| | |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
| |
| | ||||
| Thread | Thread Starter | Forum | Replies | Latest |
| Any way of programming PIC 16c54 on Velleman | bigal_scorpio | General Electronics Chat | 5 | 10th April 2008 11:05 AM |
| PIC USART-HyperTerminal problem.. | asp1987 | Micro Controllers | 17 | 8th April 2008 07:00 PM |
| PIC programming problems | rogerjef | Micro Controllers | 12 | 23rd February 2008 10:25 PM |
| PIC pin to MOSFET gate problem | Futterama | Electronic Projects Design/Ideas/Reviews | 7 | 8th November 2007 05:30 PM |
| STK500 and Tiny11 programming problem. | mramos1 | Micro Controllers | 0 | 8th May 2006 02:57 PM |