<div dir="ltr"><div>I also had this problem for a couple of years ago.</div><div>In the Programming Guide the GOTO statement is not implemented for the dsPIC33F, I took the time to find out.</div><div><br></div><div>Vinicius</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Feb 22, 2016 at 2:44 PM, Richie Burnett <span dir="ltr"><<a href="mailto:rburnett@richieburnett.co.uk" target="_blank">rburnett@richieburnett.co.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">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:<br>
<br>
bra w0<br>
goto light_red_led<br>
goto light_amber_led<br>
goto light_green_led<br>
goto light_blue_led<br>
<br>
etc...<br>
<br>
I will change the goto instructions to bra and see if it works.<br>
<br>
-Richie,<br>
<br>
<br>
<br>
-----Original Message----- From: Vinicius Brazil<br>
Sent: Monday, February 22, 2016 5:37 PM<br>
To: Richie Burnett<br>
Cc: synth-diy DIY<br>
Subject: Re: [sdiy] DSPIC computed branch and include help<div><div class="h5"><br>
<br>
<br>
HI Ritchie,<br>
I just write in assembly and use much (in all my firmware) BRA Wx statement.<br>
It works perfectly.<br>
An example of code:<br>
<br>
bra W0<br>
bra LED_SawPositive<br>
bra LED_SawNegative<br>
bra LED_SQUARE<br>
bra LED_Triangle<br>
bra LED_SINE<br>
bra LED_SquaredSine<br>
bra LED_Pulse<br>
bra LED_Noise<br>
;---------------------------------<br>
LED_SawPositive:<br>
......<br>
bra TSEnd<br>
;---------------------------------<br>
LED_SawNegative:<br>
....<br>
....<br>
....<br>
<br>
Usually I build everything in one file, but have written a program where there was an include code.<br>
I put the "include" just after the start, within the program area.<br>
<br>
regards,<br>
Vinicius<br>
<br>
<br>
<br>
<br>
On Mon, Feb 22, 2016 at 2:16 PM, Richie Burnett <<a href="mailto:rburnett@richieburnett.co.uk" target="_blank">rburnett@richieburnett.co.uk</a>> wrote:<br>
Has anyone else here using Microchips DSPIC tried to implement a computed branch using the "BRA w0" instruction ?<br>
<br>
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.<br>
<br>
Also can someone tell me the correct way to include additional assembly source files *.s in MPLAB.  I just put<br>
<br>
.include "filters.s"<br>
.include "maths.s"<br>
.include "comms.s"<br>
<br>
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!?!?<br>
<br>
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.<br>
<br>
Thanks in advance for any suggestions !<br>
<br>
-Richie,<br>
_______________________________________________<br>
Synth-diy mailing list<br>
<a href="mailto:Synth-diy@dropmix.xs4all.nl" target="_blank">Synth-diy@dropmix.xs4all.nl</a><br>
<a href="http://dropmix.xs4all.nl/mailman/listinfo/synth-diy" rel="noreferrer" target="_blank">http://dropmix.xs4all.nl/mailman/listinfo/synth-diy</a><br>
<br>
<br>
<br>
<br></div></div>
No virus found in this message.<br>
Checked by AVG - <a href="http://www.avg.com" rel="noreferrer" target="_blank">www.avg.com</a><br>
Version: 2016.0.7442 / Virus Database: 4533/11679 - Release Date: 02/22/16<br>
<br>
</blockquote></div><br></div>