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.

PIC16f1684 initialization help...PORTC works but not PORTA

Status
Not open for further replies.

TwistedE

New Member
Hi everyone,

I have a pretty simple project at hand which uses a pic16f684 and L293D motor driver to run a 12v stepper motor. Everything worked fine, motor moved, etc. when the PIC talked to the motor driver via the circuit (jpeg attachment). I'm always using the internal clock so does RA5/OSC1/CLKIN have to be grounded?

I decided to change the output ports to RA0, 1, 2 and RC0 for easier wire routing. My new code (very similar to previous one) compiles but doesn't work. None of the Port A ports are outputting any voltage at all ( i checked manually with a voltmeter ). I think I'm not initializing TRISA properly or something because everything with PORT C pins works fine.

Code:
program Prog1

DIM x as byte
DIM y as byte

 main:


 ANSEL = 0
 TRISC = $00
 TRISA = $00

 
 PORTA = $20       'Turns on a yellow led at RA5 quickly for initial testing
 PORTC = 0

 x = 0
 y = 0

delay_ms(1) ' delay of 1s



PORTA = 0
 while(1)
 
         while (x < 15)
 
               Gosub Forward
               x = x + 1
               delay_ms(2)
      
         wend
         
         PORTC = 0
         PORTA = 0
         delay_ms(500)
         
         while (y < 15)

               Gosub Reverse
               y = y + 1
               delay_ms(2)

         wend
         
         PORTC = 0
         PORTA = 0
         delay_ms(500)

         x = 0
         y = 0
 wend

 Forward:
      PORTA = $05       'STEP 1
      PORTC = $10
       delay_ms(10)
      PORTA = $06       'STEP 2
      PORTC = $10
       delay_ms(10)
      PORTA = $02       'STEP 3
      PORTC = $11
       delay_ms(10)
      PORTA = $01       'STEP 4
      PORTC = $11
       delay_ms(10)
      return

 Reverse:
      PORTA = $01       'STEP 4
      PORTC = $21
       delay_ms(10)
      PORTA = $02       'STEP 3
      PORTC = $21
       delay_ms(10)
      PORTA = $06       'STEP 2
      PORTC = $20
       delay_ms(10)
      PORTA = $05       'STEP 1
      PORTC = $20
       delay_ms(10)
       
      return
      
      
 end.
 

Attachments

  • Capture.JPG
    Capture.JPG
    69.2 KB · Views: 145
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top