Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Need help on PIC programming

Status
Not open for further replies.

ahmad

Member level 1
Joined
Jul 12, 2004
Messages
36
Helped
1
Reputation
2
Reaction score
0
Trophy points
1,286
Location
malaysia
Activity points
354
programming in pic in basic language

Hi there,

Please give me an idea to solved my problem.

I 'm using 16F84A
I create 1 variable as a memory address pointer named as pointer and i want the pic microcontroller to write a data to the address mention inside the variable address. example my data is 5 and address inside the variable pointer is 20h.

Pointer equ 10h
data equ 11h

start
movlw 0x05
movwf data ; save 5 to data variable
movlw 0x20
movwf pointer ; save 20 to variable pointer

; i want it to save the data (5) inside address 20h which is pointed by variable pointer.but fail

movf data,w
movwf pointer ; failed because it will write data 5 to memory 10h
incf pointer ; point for another memory
 

edaboad

You have to use indirect addressing. Place your address pointer value into the FSR register and then use INDF register to access RAM location:

movlw 20
movwf FSR ; point to memory location at address 20
movlw 5
movwf INDF ; write "5" to the address 20
incf FSR,F ; go to next memory location
movlw 6
movwf INDF ; write "6" to the address 21
...
 

16f84 pointer to variable

hi:
i think that if you used picbasicpro you will not need to know what kind of addressing you have to use . it is so easier for making power applications
i can help you in picbasicpro
regard
 

Thanks zristic, it works and for u matelda, please send me some info about picpro. i'm willing to learn if it will easy my job.

Thanks for both of you.
 

I would reccomend you to learn C language rather than Basic language.
C language is the high level language of choice for professional embedded programmers; the "industry standard" you could say.
You can get C compilers for almost all microcontroller and it's easier to port the code from one microcotroller to anoter than with Basic. Basic compilers are only made for very few microcontroller families like PIC, AVR and 8051.
C is more flexible than Basic and produces more compact code.
Basic is mostly used by some hobby programmers for small programs but many hobby programmers also prefer to use C.
Since you are using pointers you are alredy doing some advanced programming, so I would recccomend C rahter than Basic. In fact I would reccomed that to everyone, also beginners, C isn't that hard to learn, sombody says Basic is quicker to learn than C, but C is also quick to learn.
And you can find much more example code and expert help for C on the net than for Basic.
 

hi:
thank you me for your notes , i use basic to program pic micro and i hope to learn c to do that , so if you have good references to learn c
please tell me
regards
matelda
:?:
 

matelda said:
hi:
thank you me for your notes , i use basic to program pic micro and i hope to learn c to do that , so if you have good references to learn c
please tell me
regards
matelda
:?:
Please read this topic:


And this post:


And search EDAboad, there's several topics about this already.



matelda said:
hi:
for you ahmad to learn basic try this web
www.melabs.com
regards
matelda
I don't think he should learn Basic at all, he already knows assembly, so it would be better if he learned C instead of Basic.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top