Hi!
I am a new user of MPLAB IDE v6.20 and I have
some questions regarding the same.
I have attached a piece of the
code be that I am working with. I step through the code using
the debugger and watch SFR's - STATUS, PORTA,TRISA,ADCON1.
Though I have the correct Bank ( bank 0) for
PORT A selected, I am unable to change the contents of PORT A. I expect to have
0x08 in PORT A but its contents remain at 0x00.
However all the other registers seem to follow
the program as expected.
Please let me know how I can solve this
problem.
Also I would like to understand the meaning of
these statements
TEMP
EQU 0x20
REGA EQU
TEMP + 1 <--- What does this mean? Does it mean that 0x21 is assigned to
REGA?
MOVLW .5 <-- What does a decimal number in
place of a literal mean?
Thanks!
Vibha ; Files
required:
pic16f877.inc
*
list pf877 ; list directive to define processor #include <p16f877.inc> ; processor specific variable definitions __CONFIG _CP_OFF & _WDT_ON & _BODEN_ON & _PWRTE_ON & _RC_OSC & _WRT_ENABLE_ON & _LVP_ON & _DEBUG_OFF & _CPD_OFF ;
main BCF STATUS,RP0
BCF STATUS,RP1 CLRF PORTA MOVLW 0x08 MOVWF PORTA END ; directive 'end of program' |
|

questions abt MPLAB
Started by ●June 30, 2003
Reply by ●June 30, 20032003-06-30
Well, that is a lot of questions so I'll embed the answers! --- In , "Vibha Ravindran" <vibhar@p...> wrote: > Hi! > > I am a new user of MPLAB IDE v6.20 and I have some questions regarding the same. > > I have attached a piece of the code be that I am working with. I step through the code using the debugger and watch SFR's - STATUS, PORTA,TRISA,ADCON1. > > Though I have the correct Bank ( bank 0) for PORT A selected, I am unable to change the contents of PORT A. I expect to have 0x08 in PORT A but its contents remain at 0x00. You haven't set PORTA as output - you do this with CLRF TRISA (after selecting the appropriate bank) assuming you want all bits to be output. > > However all the other registers seem to follow the program as expected. > Please let me know how I can solve this problem. > > Also I would like to understand the meaning of these statements > TEMP EQU 0x20 > REGA EQU TEMP + 1 <--- What does this mean? Does it mean that 0x21 is assigned to REGA? Yes, that is exactly what it means but it is a poor way to do memory allocation - basically it is obsolete Try instead ;Variables in bank0 NumberOfTasks EQU 8 ; number of tasks A2DChannels EQU 4 ; number of A/D channels used BYTE EQU 1 ; byte sized allocation WORD EQU 2 ; word sized allocation CBLOCK 0x20 A2DArray: A2DChannels * BYTE ; space for A2D results Delay: NumberOfTasks * WORD ; Time slices until 1st execution Period: NumberOfTasks * WORD ; Time slices between executions RunMe: NumberOfTasks * BYTE ; Task is scheduled to run TaskIndex: BYTE ; 0..NumberOfTasks-1 PeriodTemp: WORD ; save Period while moving indirect to Delay Flags: BYTE ; see #defines below ENDC ; ; this style helps you remember what type of variable each label ; represents. Arrays are obvious, if other variables are added ; memory allocation is handled automatically and it just plain ; look good! > > MOVLW .5 <-- What does a decimal number in place of a literal mean? If the default radix is not decimal then the . is required to define a decimal number - this is probably a poor practice. I prefer to define the default radix as decimal and then use appropriate binary or hex notation when required. > > Thanks! > Vibha > ; Files required: pic16f877.inc * > > list pf877 ; list directive to define processor > #include <p16f877.inc> ; processor specific variable definitions > > __CONFIG _CP_OFF & _WDT_ON & _BODEN_ON & _PWRTE_ON & _RC_OSC & _WRT_ENABLE_ON & _LVP_ON & _DEBUG_OFF & _CPD_OFF > > ; > main > > BCF STATUS,RP0 > BCF STATUS,RP1 ; skip the BCF stuff and do BANKSEL TRISA CLRF TRISA ; set all bits to output ; or MOVLW 0x?? ; MOVWF TRISA ; your choice - depends on the hardware config BANKSEL PORTA ; yes, I know you can save an instruction or two by carefully ; keeping track of RP0 and RP1 but I like nice clean code. > CLRF PORTA > MOVLW 0x08 > MOVWF PORTA > > END ; directive 'end of program' |
|
Reply by ●June 30, 20032003-06-30
Hi, Vibha
1) At first you must to give the TRISA register the initial value with the
output and input pins (1 for input, 0 for output), and then you can use the
PORTA register.
2) the line TEMP + 1 = 0x20 + 1 = 0x21, REGA has the direction 0x21
3) the line MOVLW .5 load in the accumulator the value 5 (in decimal), is
the same MOVLW 0x05. Literal is a constant value (a number, direction,
data...)
I hope I help you, good luck
Vibha Ravindran <v...@psu.edu> wrote:
Internet GRATIS es Yahoo! Conexi. Usuario: yahoo; contrase: yahoo Desde Buenos Aires: 4004-1010 M ciudades: clic aqu/b>. |
Reply by ●June 30, 20032003-06-30
You'll have to use your imagination on the indentation - the code in my prior post looks a lot better with spaces and tabs! |
Reply by ●July 9, 20032003-07-09
Hello Vibha, From what i understand ....u r asking a question on simulation. If u want to change the value of Port A while simulating u need to go to debug-> Simulator stimulus->Asynchronous stimulus...right click and assign the pins u need RA0, RA1,..RA5. Now use pulse, high or low stimulus before u single-step through the program or animate the program. Regards, Sibi --- Vibha Ravindran <> wrote: > Hi! > > I am a new user of MPLAB IDE v6.20 and I have some > questions regarding the same. > > I have attached a piece of the code be that I am > working with. I step through the code using the > debugger and watch SFR's - STATUS, > PORTA,TRISA,ADCON1. > > Though I have the correct Bank ( bank 0) for PORT A > selected, I am unable to change the contents of PORT > A. I expect to have 0x08 in PORT A but its contents > remain at 0x00. > > However all the other registers seem to follow the > program as expected. > Please let me know how I can solve this problem. > > Also I would like to understand the meaning of these > statements > TEMP EQU 0x20 > REGA EQU TEMP + 1 <--- What does this mean? > Does it mean that 0x21 is assigned to REGA? > > MOVLW .5 <-- What does a decimal number in place of > a literal mean? > > Thanks! > Vibha > ; Files required: pic16f877.inc > * > > list pf877 ; list directive to > define processor > #include <p16f877.inc> ; processor specific > variable definitions > > __CONFIG _CP_OFF & _WDT_ON & _BODEN_ON & _PWRTE_ON > & _RC_OSC & _WRT_ENABLE_ON & _LVP_ON & _DEBUG_OFF & > _CPD_OFF > > ; > main > > BCF STATUS,RP0 > BCF STATUS,RP1 > CLRF PORTA > MOVLW 0x08 > MOVWF PORTA > > END ; directive 'end of > program' __________________________________________________ Yahoo! Plus - For a better Internet experience http://uk.promotions.yahoo.com/yplus/yoffer.html |
