Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

PIC help for newbie

Status
Not open for further replies.

sirlacksalot

New Member
Hello, I'm getting into PIC programming for robot projects and I'm stumbling a bit on a seemingly simple first test. I'm working on porting a project code from a 12C508 over to a 12F675, and even a led flash is giving me trouble.

I've run my code through a simulator, checked the datasheets, and it seems that I should be getting the my ouput pin to a logic 1 on the GPIO but even in the simulator it's not doing it. I've tried a number of different combinations, but the GPIO in the simulator never changes. It should be set to bank 0, from what I can tell.

I'm sure it's some silly thing I've overlooked, so I just wanted to ask for help on this.

Thanks in advance for any advice,
-sirlacksalot


;=================================
LIST p=12f675
#include <p12f675.inc>

LOOP1 EQU 20H
LOOP2 EQU 21H

ORG 000H ;program code to start at 000H

BSF STATUS, RP0 ; use bank 1 for setting TRISIO
MOVLW b'00011100' ; least sign bit is an input
MOVWF TRISIO ; set the inputs/outputs for GPIO
BCF STATUS, RP0 ; back to bank 0

TOP:
BCF GPIO, 0 ; bit 0 to logic 0
CALL DELAY
MOVLW b'00001111' ;
MOVWF GPIO
; BSF GPIO, 0 ; turn LED on
CALL DELAY
GOTO TOP

DELAY ; when running set LOOP1 to .250 and LOOP2 to .110.
; this will result in 250 ms delay.
MOVLW .250
MOVWF LOOP1
OUTTER
MOVLW .110 ; close to 1.0 msec delay when set to .110
MOVWF LOOP2
INNER
NOP
NOP
DECFSZ LOOP2, F ; decrement and leave result in LOOP2
; skip next statement if zero
GOTO INNER
DECFSZ LOOP1, F
GOTO OUTTER
RETURN

END
;=================================
 

Attachments

  • tank.jpg
    tank.jpg
    193.1 KB · Views: 400
You need to turn off the comparators. You do this by writting 07 to CMCON.

HTH

Mike.
 
Seems like you didn't read the Datasheet at all!

See the picture...
 

Attachments

  • analog_crap.png
    analog_crap.png
    37.4 KB · Views: 359
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top