[sdiy] DSPIC computed branch and include help

Richie Burnett rburnett at richieburnett.co.uk
Mon Feb 22 22:13:30 CET 2016


This is strange because elsewhere in my program there are a total of 37 GOTO 
statements, and other than the computed branch, the rest of the program 
assembles and runs fine.

But it does seem to the the GOTO instructions that are causing the problem 
with the computed branch routine because it works if they're swapped to BRA.

-Richie,

-----Original Message----- 
From: Vinicius Brazil
Sent: Monday, February 22, 2016 6:11 PM
To: Richie Burnett
Cc: synth-diy DIY
Subject: Re: [sdiy] DSPIC computed branch and include help


I also had this problem for a couple of years ago.
In the Programming Guide the GOTO statement is not implemented for the 
dsPIC33F, I took the time to find out.

Vinicius


On Mon, Feb 22, 2016 at 2:44 PM, Richie Burnett 
<rburnett at richieburnett.co.uk> wrote:
Your example is exactly what I'm trying to do.  But I have used the "goto" 
instruction instead of bra for some reason so it looks like:

bra w0
goto light_red_led
goto light_amber_led
goto light_green_led
goto light_blue_led

etc...

I will change the goto instructions to bra and see if it works.

-Richie,



-----Original Message----- From: Vinicius Brazil
Sent: Monday, February 22, 2016 5:37 PM
To: Richie Burnett
Cc: synth-diy DIY
Subject: Re: [sdiy] DSPIC computed branch and include help



HI Ritchie,
I just write in assembly and use much (in all my firmware) BRA Wx statement.
It works perfectly.
An example of code:

bra W0
bra LED_SawPositive
bra LED_SawNegative
bra LED_SQUARE
bra LED_Triangle
bra LED_SINE
bra LED_SquaredSine
bra LED_Pulse
bra LED_Noise
;---------------------------------
LED_SawPositive:
......
bra TSEnd
;---------------------------------
LED_SawNegative:
....
....
....

Usually I build everything in one file, but have written a program where 
there was an include code.
I put the "include" just after the start, within the program area.

regards,
Vinicius




On Mon, Feb 22, 2016 at 2:16 PM, Richie Burnett 
<rburnett at richieburnett.co.uk> wrote:
Has anyone else here using Microchips DSPIC tried to implement a computed 
branch using the "BRA w0" instruction ?

No matter what I do, I can't get it to work as explained in the programmers 
reference guide description of the BRA instruction.  It says that it should 
jump to the address (PC+2) + (2*w0)  (which makes sense because the program 
counter would already be ready to pre-fetch the next instruction, and 
instructions are aligned on 2-word boundaries,)  but instead it seems to 
jump to (PC+2) + w0  but ignores the LSB of w0, (otherwise it would produce 
a misaligned odd program counter address!)  I've checked and checked this 
and I don't see what I'm doing wrong, and can't find an errata sheet that 
mentions this problem.  Chip being used is dsPIC33FJ128GP804.

Also can someone tell me the correct way to include additional assembly 
source files *.s in MPLAB.  I just put

.include "filters.s"
.include "maths.s"
.include "comms.s"

etc... at the end of main.s but this seems to have completely broken MPLAB 
8.92.  It assembles fine, programs fine and runs fine, but goes crazy when 
hitting a breakpoint or single-stepping inside any of the included source 
files.  I'm used to the included file just popping open and the program 
counter arrow switching between whichever source window it needs to be in as 
different routines are called.  I'm actually getting the program counter 
arrow moving to lines in the source file that just have comments on them 
before the actual code starts when it should switch to one of the included 
source contents.  Also FWIW the addresses in the "Disassembly Listing" 
window are all garbled too!  It only does this when I include additional 
source files, so I must be doing something wrong!?!?

I'd like to divide the source code up into relevant sections in separate 
files to make a big project easier to follow, so really want to get this 
done right.

Thanks in advance for any suggestions !

-Richie,
_______________________________________________
Synth-diy mailing list
Synth-diy at dropmix.xs4all.nl
http://dropmix.xs4all.nl/mailman/listinfo/synth-diy




No virus found in this message.
Checked by AVG - www.avg.com
Version: 2016.0.7442 / Virus Database: 4533/11679 - Release Date: 02/22/16





No virus found in this message.
Checked by AVG - www.avg.com
Version: 2016.0.7442 / Virus Database: 4533/11679 - Release Date: 02/22/16




More information about the Synth-diy mailing list