Menu

Problems with PIC12C508A

Help
Kuiñi
2008-07-21
2013-05-30
  • Kuiñi

    Kuiñi - 2008-07-21

    I'm a new user of PICs and GCBasic and I'm trying to use the pins GPIO.0 and GPIO.1 (of PIC12C508A) as outputs, but they don't power the LEDs connected to these pins. The compiled code is the following:

    #chip 12C508A, 4
    #config INTRC_OSC, MCLRE_OFF, CP_OFF, WDT_OFF

    dir GPIO b'110111'

    Main:

    SET GPIO.0 ON
    SET GPIO.1 OFF
    WAIT 50 10ms

    SET GPIO.0 OFF
    SET GPIO.1 ON
    WAIT 50 10ms

    goto Main

    Anybody could you tell me what's the problem?

    Thank you very much for your help

     
    • kent_twt4

      kent_twt4 - 2008-07-22

      The dir looks to be backwords.  Try dir GPIO b'001000'.

       
    • Kuiñi

      Kuiñi - 2008-07-22

      Kent

      Thanks for your response. The program was modified with

      dir GPIO b'001000'

      but the problem continue.

       
    • kent_twt4

      kent_twt4 - 2008-07-22

      With a 12f509, which is of the same chip family?, compiles and works no  problems.  I'm using MPASM for the assembler.  Why don't you post your assembler file for a check.  You don't have the LEDs in backwards?  With the forum search, it appears that the 12c508 has been used with GCBasic before.

       
    • Kuiñi

      Kuiñi - 2008-07-23

      Kent:

      I have the LEDs connected correctly. My assembler file is the following:

      ;Program compiled by Great Cow BASIC (0.9 30/6/2008)
      ;Need help? See the GCBASIC forums at http://sourceforge.net/forum/?group_id=169286,
      ;check the documentation or email w_cholmondeley@users.sourceforge.net.

      ;********************************************************************************

      ;Set up the assembler options (Chip type, clock source, other bits and pieces)
      LIST p=12C508A, r=DEC
      #include <P12C508A.inc>
      __CONFIG _INTRC_OSC & _MCLRE_OFF & _CP_OFF & _WDT_OFF

      ;********************************************************************************

      ;Set aside memory locations for variables
      DELAYTEMP    equ    7
      DELAYTEMP2    equ    8
      EECON1    equ    9
      SysWaitTemp10MS    equ    10
      SysWaitTempMS    equ    11
      SysWaitTempMS_H    equ    12

      ;********************************************************************************

      ;Jump to initialisation code when PIC is reset
          ORG    0

      ;********************************************************************************

      ;Various initialisation routines, automatically called by GCBASIC
      SystemInitialise
          call    INITSYS

      ;********************************************************************************

      ;Start of the main program
          movlw    B'001000'
          tris    GPIO
      MAIN
          bsf    GPIO,0
          bcf    GPIO,1
          movlw    50
          movwf    SysWaitTemp10MS
          call    Delay_10MS
          bcf    GPIO,0
          bsf    GPIO,1
          movlw    50
          movwf    SysWaitTemp10MS
          call    Delay_10MS
          goto    MAIN
      BASPROGRAMEND
          sleep
          goto    $

      ;********************************************************************************
      ;Subroutines included in program
      ;********************************************************************************

      Delay_10MS
      D10MS_START
          movlw    10
          movwf    SysWaitTempMS
          clrf    SysWaitTempMS_H
          call    Delay_MS
          decfsz    SysWaitTemp10MS, F
          goto    D10MS_START
          retlw    0

      ;********************************************************************************

      Delay_MS
          incf    SysWaitTempMS_H, F
      DMS_START
          movlw    10
          movwf    DELAYTEMP2
      DMS_OUTER
          movlw    33
          movwf    DELAYTEMP
      DMS_INNER
          decfsz    DELAYTEMP, F
          goto    DMS_INNER
          decfsz    DELAYTEMP2, F
          goto    DMS_OUTER
          decfsz    SysWaitTempMS, F
          goto    DMS_START
          decfsz    SysWaitTempMS_H, F
          goto    DMS_START
          retlw    0

      ;********************************************************************************

      INITSYS
          movlw    B'11001111'
          option
          clrf    GPIO
          retlw    0

      ;********************************************************************************

      END

      I will to check the forum, thanks.

       
    • Jonny!!!

      Jonny!!! - 2008-07-25

      I have a 509, and I had simular problems.

      Try this code (works for me with my 509):

      #CHIP 12F508A, 4
      #CONFIG MCLRE_OFF, CP_OFF, WDT_OFF, IntRC_OSC 'run the internal osc, etc

      'main program:
      (some assembly):

      movlw b'001000' 'set output/inputs
      tris GPIO

      movlw 0x00 'set options
      option

      'your code....

      for the options, from the PIC12F508/509/16F505 Data Sheet (i forget why I did what I did when i wrote the code...)

      bit 7 GPWU: Enable Wake-up on Pin Change bit (GP0, GP1, GP3)
      1 = Disabled
      0 = Enabled
      bit 6 GPPU: Enable Weak Pull-ups bit (GP0, GP1, GP3)
      1 = Disabled
      0 = Enabled
      bit 5 T0CS: Timer0 Clock Source Select bit
      1 = Transition on T0CKI pin (overrides TRIS on the T0CKI pin)
      0 = Transition on internal instruction cycle clock, FOSC/4
      bit 4 T0SE: Timer0 Source Edge Select bit
      1 = Increment on high-to-low transition on the T0CKI pin
      0 = Increment on low-to-high transition on the T0CKI pin
      bit 3 PSA: Prescaler Assignment bit
      1 = Prescaler assigned to the WDT
      0 = Prescaler assigned to Timer0
      bit 2-0 PS<2:0>: Prescaler Rate Select bits

       
    • Kuiñi

      Kuiñi - 2008-07-25

      Jonny

      Thanks for your post, I will test your code.

       
    • Nobody/Anonymous

      You do realize that the 12C508A is a one-time programmable device (OTP), right?  So unless your program/programmer is set up to write into the unused program memory space, you are sunk.  This is hardly a device to begin experimenting with.  Use the flash memory devices (xxFxxx), instead.

      Have you got other Pics to try? and have you programmed them successfully with GCBasic?  Without knowing what your experience, budget, or projects you have in mind, it is hard to recommend a device.  A few, and always debatable, multipurpose devices that come to mind, would be:
      Low end; 12f675, 12f683 (8 pin)
      Mid; 16f88 & 18f1320 (18 pin)
      High; 16f877a, 16f887, 18f4620 (40 pin)

      If future projects will involve lengthy code, stick to the 18fxxxx devices, sometimes they are cheaper then the older 16fxxx devices anyway.

      Kent

        

       
    • Nobody/Anonymous

      Oops, my code is for the 12F, not 12C. didn't see that. I doubt my code would work anyways with that chip.

       
    • Jonny!!!

      Jonny!!! - 2008-07-26

      Oops, my code is for the 12F, not 12C. didn't see that. I doubt my code would work anyways with that chip.

       
    • Kuiñi

      Kuiñi - 2008-07-28

      Kent:

      I know that the PIC12C508A is OTP, I want to use some chips that I have. But I don't why my code does'nt woks. Thanks

       
    • kent_twt4

      kent_twt4 - 2008-08-24

      O.K. bringing this one back to the top.  Looks like the chipdata file was at fault here as [ChipData]  IntOsc = 0 when it actually has a 4mhz int osc.   So change that to IntOsc = 4 and save to disk.  Should be good to go now?

       
    • Kuiñi

      Kuiñi - 2008-08-28

      Kent

      Thanks for your help, I will buy another chip. Also I will start a topic about other application.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.