12F683 Logic Output Problem?


Closed Thread
Results 1 to 6 of 6
  1. #1
    Join Date
    Feb 2012
    Posts
    2

    Default 12F683 Logic Output Problem?

    I wrote some program but it is not working completely: It is for mosfet motor controller, HPWM section works (in TEKYON subroutine) But I can't take high logics from GPIO.0 and GPIO.5 I added program. Are there any problem?:/ I tried with 4 12F683 but all have same problem.:/

    Code:
    @ device pic12f683, fcmen_off, ieso_off, intrc_osc, wdt_off@ device pic12f683, pwrt_off, mclr_off, protect_off 
    
    
    ADCON0.7 = 1      ' Right justify result
    ANSEL = 111000 ' Set AN3 analog, rest digital
    CMCON0 = 7        ' Analog comparators off  
    INTCON = 000000 
    OSCCON = 100000 ' Internal 4MHz osc
    WPU = 0 ' Internal pull-ups = off
    trisio=10000 
    DEFINE OSC 4
    
    
    
    
    output gpio.0
    output gpio.5
    
    
    'Define ADCIN parameters
    Define ADC_BITS 8 ' Set number of bits in result
    Define ADC_CLOCK 3 ' Set clock source (3=rc)
    Define ADC_SAMPLEUS 50 ' Set sampling time in uS
    Define CCP1_REG GPIO 'PWM Output on gpio
    Define CCP1_BIT 2 'Bit 2
    Posit var Word
    Speed var byte
    x var byte
    
    
    
    
    Tekyon:
    ADCIN 3, Posit 
    HPWM 1,posit,12000
    high GPIO.0
    low GPIO.5
    Goto Tekyon 
    
    
    '*****************
    Last edited by shockwave; - 14th February 2012 at 23:28.

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default Re: 12F683 Logic Output Problem?

    Not sure about your TRIS statement, the forum might have messed it up.
    What do you have GPI0.5 set for in the TRIS?
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Feb 2012
    Posts
    2


    Did you find this post helpful? Yes | No

    Default Re: 12F683 Logic Output Problem?

    I added spaces:

    trisio= % 00010000

  4. #4
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default Re: 12F683 Logic Output Problem?

    It looks like it should work. Back up and write a program to blink an LED on GPIO.1 and 5. Just to test.
    Dave
    Always wear safety glasses while programming.

  5. #5
    Join Date
    Aug 2004
    Posts
    64


    Did you find this post helpful? Yes | No

    Default Re: 12F683 Logic Output Problem?

    Hi
    You are setting gpio.5 as input with trisio = 100000
    Only gpio.3 must be set to work as adc.
    Then the correct trisio = 1000. Or = 8
    Greetings...
    Ruben de la Pena .

  6. #6
    Join Date
    Aug 2004
    Posts
    64


    Did you find this post helpful? Yes | No

    Default Re: 12F683 Logic Output Problem?

    Sorry, my mistake...
    I did not see the data sheet and I have not used this Pic.
    I read you need use AN3 as adc input and I assumed this was at Gpio.3.
    It is at Gpio.4, then you need set trisio.4 as input and the correspondent pin at Ansel.
    But Trisio.5 MUST BE CLEARED to work as output.
    Greetings...
    Ruben de la Pena V.

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts