calibration clock 12f508


Closed Thread
Results 1 to 14 of 14
  1. #1
    Join Date
    Oct 2005
    Posts
    32

    Default calibration clock 12f508

    hi!

    f I want to use the inside (12F508) clock all it takes is writing the lace
    @ device pic12F508, intrc_osc, MCLR_OFF,WDT_OFF,PROTECT_OFF
    @ movwf OSCCAL must other be added? do you make me some example?

  2. #2
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,614


    Did you find this post helpful? Yes | No

    Angry

    Just have a look to the firsts manual pages ... there's a dedicated DEFINE !!!

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  3. #3
    Join Date
    Oct 2005
    Posts
    32


    Did you find this post helpful? Yes | No

    Default

    Hi!

    I wanted to only know if the compiler produces the code or must use of the directives in assembler?

    I must read the datasheet of the 12f508 or I must read the handbook of compiler PICBASIC PRO?

  4. #4
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,614


    Did you find this post helpful? Yes | No

    Default

    The minimum You HAVE to read is ... BOTH ...

    A look to Microchip Assembler is not too much nor, if used !!!

    ...
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  5. #5
    Join Date
    Oct 2005
    Posts
    32


    Did you find this post helpful? Yes | No

    Talking

    hi!

    ok, the forum because exists?

  6. #6
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by volcane
    hi!

    ok, the forum because exists?


    To help a person who, after exhausting other options such as reading the datasheets or the manuals, or after doing a number of tests, try, experiments, etc. is just plain stuck and needs a nudge to figure out a problem.
    Doesn't look to me like you've done any of the above...
    JDG

  7. #7
    Join Date
    Oct 2005
    Posts
    32


    Did you find this post helpful? Yes | No

    Default

    Hi!

    you have reason perfectly,but you before did not make to write the solution?

    that is:@ MOVWF OSCCAL

  8. #8
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    PBP handles this for you. It's very easy to verify.

    Compile this for a 12F508;
    Code:
    Main:
        HIGH 0
        pause 500
        low 0
        pause 500
        goto Main
    
        End
    Now simply open the .LST file, and look for it.

    ORG 0 ; Start at 0
    movwf OSCCAL ; Set oscillator calibration

    Look in your PBP manual, section 2.5.1, PICmicro MCU Specific Issues.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  9. #9
    Join Date
    Oct 2005
    Posts
    32


    Did you find this post helpful? Yes | No

    Default

    Hi!

    thanks, this is the example of like is answered to the forum

  10. #10
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default Amaziing!

    Quote Originally Posted by Bruce
    PBP handles this for you. It's very easy to verify.


    Now simply open the .LST file, and look for it.
    Hi Bruce,
    My Gosh!
    I never opened a .lst file before, I opened one, from one of my simple programs which just outputs serial strings at 4 different baud rates to test serial inputs, and wow over 32000 lines of code! What really is astounding is that the pic can process it all so fast.
    JS

  11. #11
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Yup but you'll notice many IF/IFDEF/IFNDEF wich are not process by the PIC but by the assembler. if you want to have something a little smaller, open the .asm file. on a 18F452 the single line...
    Code:
    hserout ["hello"]
    will produce
    Code:
    ; PICBASIC PRO(TM) Compiler 2.47, (c) 1998, 2006 microEngineering Labs, Inc. All Rights Reserved.  
    _USED			EQU	1
    
    	INCLUDE	"C:\PBP\18F452.INC"
    
    RAM_START       		EQU	00000h
    RAM_END         		EQU	005FFh
    RAM_BANKS       		EQU	00006h
    BANK0_START     		EQU	00080h
    BANK0_END       		EQU	000FFh
    BANK1_START     		EQU	00100h
    BANK1_END       		EQU	001FFh
    BANK2_START     		EQU	00200h
    BANK2_END       		EQU	002FFh
    BANK3_START     		EQU	00300h
    BANK3_END       		EQU	003FFh
    BANK4_START     		EQU	00400h
    BANK4_END       		EQU	004FFh
    BANK5_START     		EQU	00500h
    BANK5_END       		EQU	005FFh
    BANKA_START     		EQU	00000h
    BANKA_END       		EQU	0007Fh
    
    ; C:\PBP\PBPPIC18.RAM      	00028	FLAGS   VAR     BYTE BANKA SYSTEM       ' Static flags
    FLAGS           		EQU	RAM_START + 000h
    ; C:\PBP\PBPPIC18.RAM      	00012	R0      VAR     WORD BANKA SYSTEM       ' System Register
    R0              		EQU	RAM_START + 001h
    ; C:\PBP\PBPPIC18.RAM      	00013	R1      VAR     WORD BANKA SYSTEM       ' System Register
    R1              		EQU	RAM_START + 003h
    ; C:\PBP\PBPPIC18.RAM      	00014	R2      VAR     WORD BANKA SYSTEM       ' System Register
    R2              		EQU	RAM_START + 005h
    ; C:\PBP\PBPPIC18.RAM      	00015	R3      VAR     WORD BANKA SYSTEM       ' System Register
    R3              		EQU	RAM_START + 007h
    ; C:\PBP\PBPPIC18.RAM      	00016	R4      VAR     WORD BANKA SYSTEM       ' System Register
    R4              		EQU	RAM_START + 009h
    ; C:\PBP\PBPPIC18.RAM      	00017	R5      VAR     WORD BANKA SYSTEM       ' System Register
    R5              		EQU	RAM_START + 00Bh
    ; C:\PBP\PBPPIC18.RAM      	00018	R6      VAR     WORD BANKA SYSTEM       ' System Register
    R6              		EQU	RAM_START + 00Dh
    ; C:\PBP\PBPPIC18.RAM      	00019	R7      VAR     WORD BANKA SYSTEM       ' System Register
    R7              		EQU	RAM_START + 00Fh
    ; C:\PBP\PBPPIC18.RAM      	00020	R8      VAR     WORD BANKA SYSTEM       ' System Register
    R8              		EQU	RAM_START + 011h
    ; C:\PBP\PBPPIC18.RAM      	00027	GOP     VAR     BYTE BANKA SYSTEM       ' Gen Op Parameter
    GOP             		EQU	RAM_START + 013h
    ; C:\PBP\PBPPIC18.RAM      	00023	RM1     VAR     BYTE BANKA SYSTEM       ' Pin 1 Mask
    RM1             		EQU	RAM_START + 014h
    ; C:\PBP\PBPPIC18.RAM      	00026	RM2     VAR     BYTE BANKA SYSTEM       ' Pin 2 Mask
    RM2             		EQU	RAM_START + 015h
    ; C:\PBP\PBPPIC18.RAM      	00021	RR1     VAR     BYTE BANKA SYSTEM       ' Pin 1 Register
    RR1             		EQU	RAM_START + 016h
    ; C:\PBP\PBPPIC18.RAM      	00024	RR2     VAR     BYTE BANKA SYSTEM       ' Pin 2 Register
    RR2             		EQU	RAM_START + 017h
    ; C:\PBP\PBPPIC18.RAM      	00022	RS1     VAR     BYTE BANKA SYSTEM       ' Pin 1 Bank
    RS1             		EQU	RAM_START + 018h
    ; C:\PBP\PBPPIC18.RAM      	00025	RS2     VAR     BYTE BANKA SYSTEM       ' Pin 2 Bank
    RS2             		EQU	RAM_START + 019h
    ; C:\PBP\18F452.BAS        	00024	PORTL   VAR     PORTB
    _PORTL           		EQU	 PORTB
    ; C:\PBP\18F452.BAS        	00025	PORTH   VAR     PORTC
    _PORTH           		EQU	 PORTC
    ; C:\PBP\18F452.BAS        	00026	TRISL   VAR     TRISB
    _TRISL           		EQU	 TRISB
    ; C:\PBP\18F452.BAS        	00027	TRISH   VAR     TRISC
    _TRISH           		EQU	 TRISC
    
    ; EEPROM data.
    
    
    	INCLUDE	"A.MAC"
    	INCLUDE	"C:\PBP\PBPPIC18.LIB"
    
    
    ; C:\PBP\18F452.BAS        	00012	BANKA   $0000, $007F
    ; C:\PBP\18F452.BAS        	00013	BANK0   $0080, $00FF
    ; C:\PBP\18F452.BAS        	00014	BANK1   $0100, $01FF
    ; C:\PBP\18F452.BAS        	00015	BANK2   $0200, $02FF
    ; C:\PBP\18F452.BAS        	00016	BANK3   $0300, $03FF
    ; C:\PBP\18F452.BAS        	00017	BANK4   $0400, $04FF
    ; C:\PBP\18F452.BAS        	00018	BANK5   $0500, $05FF
    ; C:\PBP\18F452.BAS        	00020	LIBRARY "PBPPIC18"
    
    ; C:\PBP\18F452.BAS        	00022	        include "PIC18EXT.BAS"
    
    ; C:\PBP\18F452.BAS        	00029	        include "PBPPIC18.RAM"
    
    ; C:\PBP_PROG\A.BAS        	00001	       hserout ["hello"]
    	HSEROUT?C	068h
    	HSEROUT?C	065h
    	HSEROUT?C	06Ch
    	HSEROUT?C	06Ch
    	HSEROUT?C	06Fh
    
    	END
    the interesting stuff is HSEROUT?C. now open the .MAC file, it produce...
    Code:
    	NOLIST
    ; PICBASIC PRO(TM) Compiler 2.47, (c) 1998, 2006 microEngineering Labs, Inc. All Rights Reserved.  
    
    HSEROUT?C macro Cin
            MOVE?CA Cin
            L?CALL  HSEROUT
        endm
    HSEROUT_USED = 1
    
    
    	LIST
    so you know that it store each character (C) in Wreg(A), and then call the HSEROUT sub.
    Last edited by mister_e; - 4th December 2006 at 23:16.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  12. #12
    Join Date
    May 2006
    Location
    Del Rio, TX, USA
    Posts
    343


    Did you find this post helpful? Yes | No

    Default

    Joe, not all of what you see is executed by the PIC (really only a small portion). Here is a snippet of a .lst file. Only what is highlighted in RED are actual lines of code which find there way into the PIC:

    Code:
      00000032            00472 _timeloopconst                  EQU     00032h
      00000064            00473 _timeloopMAX                    EQU     00064h
                          00474         INCLUDE "MAIN_4.MAC"
                          00001 
                          01236         LIST
                          00475         INCLUDE "C:\PBP\PBPPIC18.LIB"
                          00001 ;******************************************************************
                          00002 ;*  PBPPIC18.LIB                                                  *
                          00003 ;*                                                                *
                          00004 ;*  By        : Leonard Zerman, Jeff Schmoyer                     *
                          00005 ;*  Notice    : Copyright (c) 2005 microEngineering Labs, Inc.    *
                          00006 ;*              All Rights Reserved                               *
                          00007 ;*  Date      : 09/22/05                                          *
                          00008 ;*  Version   : 2.46a                                             *
                          00009 ;*  Notes     :                                                   *
                          00010 ;******************************************************************
                          00124   LIST
                          00125 ; Oscillator is 40MHz
                          01131   LIST
    000000                01132     ORG RESET_ORG               ; Reset vector at 0
                          01136   LIST
    000000 6A1C           01137         clrf    FLAGS           ; Clear all flags on reset
                          01141   LIST
    000002 EF4A F002      01142         goto    INIT            ; Finish initialization
                          01152   LIST
    000008                01153     ORG RESET_ORG + 8           ; High priority interrupt vector at 8
    
    000008 EF69 F002      01154         goto    INTHAND         ; Goto high priority user interrupt handler
                          01166   LIST
    000018                01167     ORG RESET_ORG + 18h         ; Low priority interrupt vector at 18h
    000018 EF8F F002      01168         goto    INTLHAND        ; Goto low priority user interrupt handler
                          02164   LIST
    00001C 50E9           02165 HSEROUTJ movf   FSR0L, W        ; Jumpman entry
                          02171   LIST
    00001E                02172 HSEROUT
                          02173         CLRWDT?                 ; Keep Watchdog clear
                              M     ifndef NO_CLRWDT
    00001E 0004               M         clrwdt
                              M     endif
    000020 A89E           02174         btfss   PIR, TXIF       ; Wait till ready
    000022 D7FD           02175         bra     HSEROUT
                          02176 
                          02177      ifdef HSERPARITY_USED
                          02178           if (HSER_BITS != 9)
                          02179         andlw   7fh             ; Clear top bit
                          02180         rcall   HSERPARITY      ; Calculate the parity
                          02181             ifdef HSER_ODD
                          02182         btfss   GOP, 0
                          02183             else
                          02184         btfsc   GOP, 0
                          02185             endif
                          02186         iorlw   80h             ; Set parity
                          02187           else
                          02188         rcall   HSERPARITY      ; Calculate the parity
                          02189         bcf     TXSTA, TX9D     ; Start parity at 0
                          02190             ifdef HSER_ODD
                          02191         btfss   GOP, 0
                          02192             else
                          02193         btfsc   GOP, 0
                          02194             endif
                          02195         bsf     TXSTA, TX9D     ; Set parity in 9th bit
                          02196           endif
                          02197       endif
                          02198 
    000024 6EAD           02199         movwf   TXREG           ; Send the char
    000026 80D8           02200         bsf     STATUS, C       ; Set no timeout for Serout2mod
    000028 EF47 F002      02201         goto    DUNN            ; That's it
    The other colors are:
    BLUE = Declarations, processed by assembler
    ORANGE= Assembler commands, directives, macros
    GREEN = Comments
    PURPLE= Labels

    Also, here is a little legend for the lines of code:
    Code:
     PIC   Commands        ASM             Commands			
    line#  in HEX         line#             in ASM        .        
    000024 6EAD           02199         movwf   TXREG           ; Send the char
    000026 80D8           02200         bsf     STATUS, C       ; Set no timeout for Serout2mod
    000028 EF47 F002      02201         goto    DUNN            ; That's it
    
    EDIT: Maybe some better discriptors:
       PIC line# = ADDRESS in PIC program memory
       Commands in HEX = PIC Object Code (or OPCODE or Instruction)
       Commands in ASM = Source Code

    Hope this helps you in your understanding of what goes on "under the hood"

    SteveB
    Last edited by SteveB; - 5th December 2006 at 04:43.

  13. #13
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    Nice example SteveB, a kind of tutorial.

    Helpful in understanding indeed.


    ---------------------
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  14. #14
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default Under the hood . . .

    Quote Originally Posted by SteveB
    Joe, not all of what you see is executed by the PIC (really only a small portion). Here is a snippet of a .lst file. Only what is highlighted in RED are actual lines of code which find there way into the PIC:

    Code:
      00000032            00472 _timeloopconst                  EQU     00032h
      00000064            00473 _timeloopMAX                    EQU     00064h
                          00474         INCLUDE "MAIN_4.MAC"
                          00001 
                          01236         LIST
                          00475         INCLUDE "C:\PBP\PBPPIC18.LIB"
                          00001 ;******************************************************************
                          00002 ;*  PBPPIC18.LIB                                                  *
                          00003 ;*                                                                *
                          00004 ;*  By        : Leonard Zerman, Jeff Schmoyer                     *
                          00005 ;*  Notice    : Copyright (c) 2005 microEngineering Labs, Inc.    *
                          00006 ;*              All Rights Reserved                               *
                          00007 ;*  Date      : 09/22/05                                          *
                          00008 ;*  Version   : 2.46a                                             *
                          00009 ;*  Notes     :                                                   *
                          00010 ;******************************************************************
                          00124   LIST
                          00125 ; Oscillator is 40MHz
                          01131   LIST
    000000                01132     ORG RESET_ORG               ; Reset vector at 0
                          01136   LIST
    000000 6A1C           01137         clrf    FLAGS           ; Clear all flags on reset
                          01141   LIST
    000002 EF4A F002      01142         goto    INIT            ; Finish initialization
                          01152   LIST
    000008                01153     ORG RESET_ORG + 8           ; High priority interrupt vector at 8
    
    000008 EF69 F002      01154         goto    INTHAND         ; Goto high priority user interrupt handler
                          01166   LIST
    000018                01167     ORG RESET_ORG + 18h         ; Low priority interrupt vector at 18h
    000018 EF8F F002      01168         goto    INTLHAND        ; Goto low priority user interrupt handler
                          02164   LIST
    00001C 50E9           02165 HSEROUTJ movf   FSR0L, W        ; Jumpman entry
                          02171   LIST
    00001E                02172 HSEROUT
                          02173         CLRWDT?                 ; Keep Watchdog clear
                              M     ifndef NO_CLRWDT
    00001E 0004               M         clrwdt
                              M     endif
    000020 A89E           02174         btfss   PIR, TXIF       ; Wait till ready
    000022 D7FD           02175         bra     HSEROUT
                          02176 
                          02177      ifdef HSERPARITY_USED
                          02178           if (HSER_BITS != 9)
                          02179         andlw   7fh             ; Clear top bit
                          02180         rcall   HSERPARITY      ; Calculate the parity
                          02181             ifdef HSER_ODD
                          02182         btfss   GOP, 0
                          02183             else
                          02184         btfsc   GOP, 0
                          02185             endif
                          02186         iorlw   80h             ; Set parity
                          02187           else
                          02188         rcall   HSERPARITY      ; Calculate the parity
                          02189         bcf     TXSTA, TX9D     ; Start parity at 0
                          02190             ifdef HSER_ODD
                          02191         btfss   GOP, 0
                          02192             else
                          02193         btfsc   GOP, 0
                          02194             endif
                          02195         bsf     TXSTA, TX9D     ; Set parity in 9th bit
                          02196           endif
                          02197       endif
                          02198 
    000024 6EAD           02199         movwf   TXREG           ; Send the char
    000026 80D8           02200         bsf     STATUS, C       ; Set no timeout for Serout2mod
    000028 EF47 F002      02201         goto    DUNN            ; That's it
    The other colors are:
    BLUE = Declarations, processed by assembler
    ORANGE= Assembler commands, directives, macros
    GREEN = Comments
    PURPLE= Labels

    Also, here is a little legend for the lines of code:
    Code:
     PIC   Commands        ASM             Commands			
    line#  in HEX         line#             in ASM        .        
    000024 6EAD           02199         movwf   TXREG           ; Send the char
    000026 80D8           02200         bsf     STATUS, C       ; Set no timeout for Serout2mod
    000028 EF47 F002      02201         goto    DUNN            ; That's it
    
    EDIT: Maybe some better discriptors:
       PIC line# = ADDRESS in PIC program memory
       Commands in HEX = PIC Object Code (or OPCODE or Instruction)
       Commands in ASM = Source Code

    Hope this helps you in your understanding of what goes on "under the hood"

    SteveB
    Thanks Steve,
    It does a little, sorta like explaining fuel injection and closed loop control to your wife ugh meaning absolutly no disrespect to the female gender whom I have always suspected were smarter than we, but I get this much: only a small portion of that code goes in the hex file and the rest controls the assembler / linker etc. Maybe your post should go into the code examples area or perhaps a new area . . . tutorials ?
    JS

Similar Threads

  1. Single digit 7 Seg LED clock - PIC16F88
    By thirsty in forum Code Examples
    Replies: 4
    Last Post: - 17th July 2009, 08:42
  2. UberNewbie can't set his clock...
    By Byte_Butcher in forum General
    Replies: 19
    Last Post: - 7th January 2009, 04:22
  3. EM4095 Chip, get Clock and Data signals?
    By mindthomas in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 19th August 2008, 06:27
  4. Shiftout/in
    By BobEdge in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 23rd August 2007, 11:48
  5. Help with sound command in 2 programs
    By hyperboarder in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 5th July 2007, 20:36

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