Timer does not work 12F675


Closed Thread
Results 1 to 13 of 13

Hybrid View

  1. #1


    Did you find this post helpful? Yes | No

    Default

    Try this:

    Code:
    @ DEVICE PIC12F675, INTRC_OSC_NOCLKOUT
    	' System Clock Options (Internal)	
    @ DEVICE PIC12F675, WDT_ON
    	' Watchdog Timer
    @ DEVICE PIC12F675, PWRT_ON
    	' Power-On Timer
    @ DEVICE PIC12F675, MCLR_OFF
    	' Master Clear Options (Internal)
    @ DEVICE PIC12F675, BOD_ON
    	' Brown-Out Detect
    @ DEVICE PIC12F675, CPD_OFF
    	' Data Memory Code Protect
    @ DEVICE PIC12F675, PROTECT_OFF
    	' Program Code Protection
    
        DEFINE  ADC_BITS        10  ' Set resolution of conversion
        DEFINE  ADC_CLOCK       3   ' Set clock source (x/FOSC or FRC)
        DEFINE  ADC_SAMPLEUS    50  ' Set sampling time (in uS)
    
        DEFINE OSCCAL_1K 1
        DEFINE OSCCAL_2K 1
    
        ANSEL = %00000000               ' Set analog ports to digital mode
        ADCON0 = %10000001              ' Configure A/D channel
        CMCON = %00000111               ' Turn off comparator
        WPU = %00000000                 ' Disable pull-ups
        TRISIO = %00000                 ' Set all I/O's to outputs
    
    
        i           var     byte        ' Counter variable
        test_led    var     gpio.1
        led         var     gpio.2
    
        test_led = 0
        led = 0
    
    main:
        for i = 0 to 59
            test_led = 1
            pause 500
            test_led = 0
            pause 500
            next i
        toggle led
        goto main

  2. #2


    Did you find this post helpful? Yes | No

    Smile Errors!

    Hello,

    It gives the following error me

    Thanks
    Attached Images Attached Images  

  3. #3


    Did you find this post helpful? Yes | No

    Default

    Oops, the config fuses were set to PM assembler. This is the correct code to MPASM. Sorry about that.

    Code:
    @ __CONFIG _INTRC_OSC_NOCLKOUT & _WDT_ON & _PWRTE_ON & _MCLRE_OFF & _BODEN_ON & _CPD_OFF & _CP_OFF
    	' System Clock Options (Internal)	
    	' Watchdog Timer
    	' Power-On Timer
    	' Master Clear Options (Internal)
    	' Brown-Out Detect
    	' Data Memory Code Protect
    	' Program Code Protection
    Are you sure your running v1.45 and not v2.45. That would have to be pretty old if that is correct.
    Last edited by CocaColaKid; - 21st September 2005 at 21:23.

  4. #4


    Did you find this post helpful? Yes | No

    Smile

    Hello,

    The code I cannot compile it with the PBC???.





    Quote Originally Posted by CocaColaKid
    Oops, the config fuses were set to PM assembler. This is the correct code to MPASM. Sorry about that.

    Code:
    @ __CONFIG _INTRC_OSC_NOCLKOUT & _WDT_ON & _PWRTE_ON & _MCLRE_OFF & _BODEN_ON & _CPD_OFF & _CP_OFF
    	' System Clock Options (Internal)	
    	' Watchdog Timer
    	' Power-On Timer
    	' Master Clear Options (Internal)
    	' Brown-Out Detect
    	' Data Memory Code Protect
    	' Program Code Protection
    Are you sure your running v1.45 and not v2.45. That would have to be pretty old if that is correct.

  5. #5


    Did you find this post helpful? Yes | No

    Smile

    I have version 1.45

    Thanks

  6. #6


    Did you find this post helpful? Yes | No

    Default

    Oh, what a dummy I am. I thought you were using PBP. I'm not sure what the differences are since I use PBP and it works fine for me. I can't even try to compile it so I'm not too much help unfortunately.

  7. #7


    Did you find this post helpful? Yes | No

    Smile

    Then I must compile it with PBP?.

    Thanks

  8. #8


    Did you find this post helpful? Yes | No

    Smile

    Hello,
    I have PICBASIC 1,45 and gives errors.

    Thanks




    Quote Originally Posted by CocaColaKid
    Try this:

    Code:
    @ DEVICE PIC12F675, INTRC_OSC_NOCLKOUT
    	' System Clock Options (Internal)	
    @ DEVICE PIC12F675, WDT_ON
    	' Watchdog Timer
    @ DEVICE PIC12F675, PWRT_ON
    	' Power-On Timer
    @ DEVICE PIC12F675, MCLR_OFF
    	' Master Clear Options (Internal)
    @ DEVICE PIC12F675, BOD_ON
    	' Brown-Out Detect
    @ DEVICE PIC12F675, CPD_OFF
    	' Data Memory Code Protect
    @ DEVICE PIC12F675, PROTECT_OFF
    	' Program Code Protection
    
        DEFINE  ADC_BITS        10  ' Set resolution of conversion
        DEFINE  ADC_CLOCK       3   ' Set clock source (x/FOSC or FRC)
        DEFINE  ADC_SAMPLEUS    50  ' Set sampling time (in uS)
    
        DEFINE OSCCAL_1K 1
        DEFINE OSCCAL_2K 1
    
        ANSEL = %00000000               ' Set analog ports to digital mode
        ADCON0 = %10000001              ' Configure A/D channel
        CMCON = %00000111               ' Turn off comparator
        WPU = %00000000                 ' Disable pull-ups
        TRISIO = %00000                 ' Set all I/O's to outputs
    
    
        i           var     byte        ' Counter variable
        test_led    var     gpio.1
        led         var     gpio.2
    
        test_led = 0
        led = 0
    
    main:
        for i = 0 to 59
            test_led = 1
            pause 500
            test_led = 0
            pause 500
            next i
        toggle led
        goto main
    Attached Images Attached Images  

Similar Threads

  1. Elapsed Timer Demo
    By Darrel Taylor in forum Code Examples
    Replies: 111
    Last Post: - 29th October 2012, 18:39
  2. Timer interrupt frequency
    By Samoele in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 18th January 2009, 00:49
  3. Simple "backround" timer
    By peterdeco1 in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 12th November 2005, 06:11
  4. Timer Of 40 Days 12f675 Or 16f628
    By Leonardo in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 21st August 2005, 01:11
  5. Pin RA4 doesn't work
    By Melanie in forum FAQ - Frequently Asked Questions
    Replies: 0
    Last Post: - 15th July 2004, 13:03

Members who have read this thread : 0

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