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?
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?
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 " !!!
*****************************************
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?
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 " !!!
*****************************************
Originally Posted by volcane
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
Hi!
you have reason perfectly,but you before did not make to write the solution?
that is:@ MOVWF OSCCAL
PBP handles this for you. It's very easy to verify.
Compile this for a 12F508;
Now simply open the .LST file, and look for it.Code:Main: HIGH 0 pause 500 low 0 pause 500 goto Main End
ORG 0 ; Start at 0
movwf OSCCAL ; Set oscillator calibration
Look in your PBP manual, section 2.5.1, PICmicro MCU Specific Issues.
Hi Bruce,Originally Posted by 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
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...
will produceCode:hserout ["hello"]
the interesting stuff is HSEROUT?C. now open the .MAC file, it 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
so you know that it store each character (C) in Wreg(A), and then call the HSEROUT sub.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
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.
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:
The other colors are: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
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.
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
Thanks Steve,Originally Posted by SteveB
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
Bookmarks