![]() | ![]() | ![]() |
| | |||||||
| Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc. |
| | LinkBack | Thread Tools | Display Modes |
| | (permalink) |
| I'm trying to use 16f628's porta as an output but for some reason it doesn't work. at least when i'm simulating with mplab's simulator. the problem is that i cannot change the state of porta's 0-3 pins. They are always 0. so only RA4 is working. my code is: LIST P=16F628 radix hex #include "P16F628.INC" ; Include header file __config _INTRC_OSC_NOCLKOUT & _LVP_OFF & _WDT_OFF & _PWRTE_ON & _BODEN_ON ORG 0x000 ; Program starts at 0x000 BSF STATUS,RP0 ; bank 1 CLRF TRISA ;all output BCF STATUS,RP0 ; back to bank 0 CLRF PORTA LOOP: BSF PORTA,4 ;RA4 goes up BCF PORTA,4 ;RA4 goes down BSF PORTA,3 ;nothing happens BSF PORTA,2 ;nothing happens BSF PORTA,1 ;nothing happens BSF PORTA,0 ;nothing happens GOTO LOOP END can you see any clear errors or have you had same kind of problem?? Or is the error in simulator?? a | |
| |
| | (permalink) |
| PIC 16F628 has comparators on portA. They are ON by default, so if you want ,to use portA pins as normal I/O you must first turn the comparator off Add the following lines to the top of your code MOVLW 0x07 MOVWF CMCON | |
| |
| | (permalink) |
| It works.thanks.great site.. a | |
| |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
| |