Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

dsPIC linker script for asm

Status
Not open for further replies.

futz

Active Member
I guess I'm the only guy in the world who wants to program my dsPIC in assembler. :D

The asm30 assembler/linker package is totally geared toward C programming. I don't like C, though I can live with it if necessary. I may end up going that way. Path of least resistance, ya know? :p

I haven't written a linker script in decades, and they've gotten very complex. Anybody have a script for pure asm coding?

I have all the Microchip docs already, and am slowly puzzling my way thru the linker documentation. But I may never finish, since it's 100% C focused.

A long time ago I did some PC assembler programming where I wimped out and just used a C skeleton and then all inline assembly for the actual code. (Later I learned better ways). Might be easier to do that than get pure asm working? I don't know...
 
I also think that ASM30 is a real step backwards in ease of use.

I have been programming a pic24FJ32GA002 in assembler.

I had some help from Microchip but it still
1) needed adjustment to work
2) totally biased for C

I had real trouble getting the assembler to put the GOTO 0x200 at the start of the code, which I did by changing the __reset line in the attatched .gld file

Anyhow, this works and my code starts:-

.include "p24FJ32GA002.inc"

config __CONFIG2, IESO_OFF & FNOSC_SOSC & FCKSM_CSECMD & OSCIOFNC_ON & IOL1WAY_OFF & I2C1SEL_PRI & POSCMOD_EC
config __CONFIG1, JTAGEN_OFF & GCP_OFF & GWRP_OFF & BKBUG_OFF & COE_OFF & ICS_PGx1 & FWDTEN_ON & WINDIS_OFF & FWPSA_PR32 & WDTPS_PS32768


.text


mov #0b0001101111001110, w0
mov w0, AD1PCFG


and it works.
 

Attachments

  • p24FJ32GA002.zip
    17.8 KB · Views: 225
Holy crap!!! I'm SO rusty in C! :p It's been ages since I wrote any C at all.

I've got the dsPIC blinking LEDs but the code is embarrassingly horrible. I'm totally fumbling, and will be for a while yet.

The PICkit2 software has a wonderful feature called "Auto Import Hex + Write Device". When you successfully compile your program in MPLAB and the hex file changes, the PICkit2 program auto-imports the file and programs the chip (and if you have the VDD box checked, runs it). All you have to do is hit F10 and the rest is automatic. Very nice! :D
 
Last edited:
I found the program on button is handy for doing bulk programming. I use this method to program the Junebug PIC using a Junebug.
 
I wanted to use ASM30 last time. I've printed out the instructions, but o_O :p
Then I end up with C30, it's not that difficult.
 
bananasiong said:
I wanted to use ASM30 last time. I've printed out the instructions, but o_O :p
Then I end up with C30, it's not that difficult.
Ya, I think I may end up doing exactly that. I never hated C - just didn't care for it much. And once you have the basics of C straightened out it's very easy to just switch to inline assembler inside your C program if you want. Very simple that way.
 
futz said:
Ya, I think I may end up doing exactly that. I never hated C - just didn't care for it much. And once you have the basics of C straightened out it's very easy to just switch to inline assembler inside your C program if you want. Very simple that way.


I think once you started using C and got used to it you might not want to use assmbler again.
 
futz said:
I've got the dsPIC blinking LEDs
Coupla pics. Went back to the much more convenient long cable. The chip is no more picky than a regular 8-bit PIC, as far as I can tell. It doesn't care if I remove the capacitors either. I never use em on most projects, though if I was building something not just for play I'd put em in.

**broken link removed**

She's blipping LEDs at 118MHz - Internal 7.37MHz clock with 16x PLL. Very speedy.

**broken link removed**
 
Last edited:
futz said:
The PICkit2 software has a wonderful feature called "Auto Import Hex + Write Device". When you successfully compile your program in MPLAB and the hex file changes, the PICkit2 program auto-imports the file and programs the chip (and if you have the VDD box checked, runs it).

WinPicProg has done that for a long time, a couple of menu options allow you to allow auto-reloading of a changed HEX file, and auto-programming once loaded.

To be honest, while it initially seems really great, after a while it starts to wear a little! :D
 
Oh ya, about this auto import hex + write. If there is any typo or any error during the assembling or compiling, PICkit2 programming software will show error, which is quite annoying, for me :)
 
Check his posts

Hola Futz,

You seem having changed your mind already. But you could read the SO MANY post this guy made on the linker subject at the Microchip forum

http://forum.microchip.com/showprofile.aspx?memid=22544

He seems to be the one who knows it better and has lot about it in his site.

Lot of posts where he talked about.
 
bananasiong said:
Oh ya, about this auto import hex + write. If there is any typo or any error during the assembling or compiling, PICkit2 programming software will show error, which is quite annoying, for me :)

That's interesting, if there's an error during assembly, then no new HEX file is created, WinPicProg checks for a changed file date on the HEX file, so if assembly fails it doesn't reload the file. PICKit2 is obviously more integrated with MPLAB.
 
Yup, that's true. The message of "Error loading hex file: write aborted".

Nigel Goodwin said:
PICKit2 is obviously more integrated with MPLAB.
But PICkit2 software supports more PIC than MPLAB.
 
bananasiong said:
Yup, that's true. The message of "Error loading hex file: write aborted".


But PICkit2 software supports more PIC than MPLAB.

I thought PICKit2 only supported a fairly small number of devices, and MPLAB supported them all?.
 
bananasiong said:
Yup, that's true. The message of "Error loading hex file: write aborted".

This only happens if the hex file changes during loading. If you have errors then the hex file isn't changed and doesn't get reloaded.

Mike.
 
Nigel Goodwin said:
I thought PICKit2 only supported a fairly small number of devices, and MPLAB supported them all?.

Actually it's the other way around. PICkit2 software supports almost every Flash PIC (program only), it even supports a handful of SPI, I2C EEPROMs.
MPLAB can program & debug most 8bit PICs, it's catching up with the 16bit ones but not much yet.
 
What's the use of Linker script file? for PIC mcu?

Dear friends,

What's the use of Linker script file?
For PIC mcu, there's so many different Linker script files.
Say:
PIC 18F2420.lkr
PIC 18F2420i.lkr
PIC 18F2420e.lkr

I used ICD2.
It come out with an error saying "address error ..." for Org 0x0, Org 0x0008 (those are default interrupt routine address)

And when I remove the linker script file, the errors gone? Why???
 
Status
Not open for further replies.

Latest threads

Back
Top