"...OK - did I miss something here.. How the hell did this topic get from discussing telescope drives to discussing the merrits of death row ???
I gather the original poster gave up in the end and purchased a commercial driver. Maybe because the topic went way off topic, maybe as purchasing a ready made alternative to developing his own was the easy option...."
No, I'm actually just waiting here for the off-topic discussion to die down. I went and purchased a commercial microstepping chip to use instead of the L293D, but I still expect to drive it using a PIC. In fact, I have some more problems now, because I thought PIC assembler was fairly simple, and it turns out not to be!
I am confused by the memory allocation of variables. As far as I can see, a PIC .ASM file comprises a set of memory declarations followed by some commands. Variables are defined by naming them and giving their locations, thus:
VAR1 EQU H'10' ;defines the location H10 as VAR1
VAR2 EQU H'22' ;defines the location H22 as VAR2
and then you can load them:
MOVLW D'5'
MOVWF VAR1 ;puts 5 in VAR1 (location H10)
.
.
MOVLW VAR1 ;puts 5 back in the W Register
and generally play with them. But when I try to alter the program I have, it complains that some of the variables I create are in 'Restricted Memory'. I can't find any way to work out what is legal memory and what isn't. I have tried putting variable in random places until the error goes away, and then I hit the next problem, which seems to be that other processes also write to the memory locations I am using, so every so often my counts jump up by 20 or so. There are several simple tutorials on the web for blinking LEDs, but none seem to cover this sort of problem...
Welcome back
Which chip you're using right now? For each PIC, there's some dedicated places for the GPR. Look your datasheet under Data Memory Map, and see where you can sit your General Purpose Registers.
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
>>MOVLW VAR1 ;puts 5 back in the W Register
I am not sure if it is important to you, but this line puts 16 into W (not 5).
MOVF VAR1, W
would put 5 back into W
Paul Borgmeier
Salt Lake City, UT
USA
__________________
Hi, All,
I'm still using the PIC16F627. Thanks to Mister-E for pointing me at the data sheet (all 170 pages!!). I see that the data memory map is in 4 banks (I thought it was 2), and that there is a difference between 'unimplemented data locations' and 'general purpose registers' (which I don't understand). I had been putting my counts in the unimplemented slots, and they seemed to vary when I didn't touch them. Now I am putting them at H'20' onwards.
Where does the actual program code go? There seems to be no indication of this.
Paul has put his finger on one of my problems - I could not (and still can't) understand why MOVLW VAR1 does not put the contents of location VAR1 into the W register. And in my example, where VAR1 is D'5', where does the 16 come from? Is it D'16', or H'16'? But thanks, Paul - I used your recommendation and now my counts have improved considerably...even though I still don't know why!
I will stick with trying to make this motor work - buying a different microstep driver chip has required a different veroboard circuit, so I have been learning circuit design - VERODES is a really easy program to use for this purpose. Once I have cracked the code issues we will have another go at making this scope turn!
Small and short explanation here...
There's a slight difference between Literal and Registers
MOVLW Move the literal in W.
Literal is a constant, when you're using a variable in there.. it return the constant associated to your variable... it's address
MOVLW .10 will copy 10 (decimal) in W
<hr>
MOVF Move register to x destination (F or W)
Rough explanation... Registers are variable... mean that you can change register value, not their address
MOVF YourVar,W will copy the value of YourVar to W
MOVF PORTB,W read PORTB, and store it to W
<hr>
from this linewhere does the 16 come from? Is it D'16', or H'16'?
VAR1 EQU H'10'
10hex = 16 Decimal
<hr>
go one page before in your datasheet Memory Organization . Your actual code begin a RESET_VECTOR 0x000. You have different block, Program Memory, Data Memory and EEPROM data. Data memory are your PIC register and your GPRsWhere does the actual program code go? There seems to be no indication of this.
<hr>
Unimplemented.. you just can't use them.. not much
<hr>
170 pages... well that's one of those small. I have some which have over 700, and some can't be download in one shot... DsPIC are good example... you must download the whole reference family set + the one for your DsPIC... kinda load of reading before getting comfortable with.
Oh well, don't be afraid, those datasheet looks way bigger when you begin.
Last edited by mister_e; - 11th April 2008 at 10:55.
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
Oooh..er. That's my reading for the rest of the day!
But I have one question (lots actually, but most will have to wait). You say that:
VAR1 EQU H'10'
makes the variable VAR1 equal to H'10'. I thought it made the memory register at location '10' addressable as VAR1. If EQU is the command for loading initial values of variables, what is the command for locating them at appropriate places in memory?
Bookmarks