[sdiy] DSPIC computed branch and include help
Richie Burnett
rburnett at richieburnett.co.uk
Mon Feb 22 22:39:56 CET 2016
That's it! Thanks Scott. The GOTO instruction takes up two instruction locations in program memory! I knew it took 2 instruction cycles of time to execute a GOTO operation because of the instruction pipeline, but I had always thought all Dspic instructions were the same size in program memory. It's right there in the programmers reference manual though that it takes up 2 words.
The BRA Wx instruction works correctly when it's followed by single word branch instructions instead of dual-word GOTOs. I'm just surprised it didn't generate an exception or something branching into the middle of a two-word instruction! At least then I would have realised what was wrong.
Thanks for the help, now I just need to figure out why MPLAB debug and simulation won't follow program execution into multiple included source files. Had I actually been able to single-step the program execution into included sources I would have solved the computed branch bug much quicker.
-Richie,
Sent from my Xperia SP on O2
---- Scott Gravenhorst wrote ----
>"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.
>
>The GOTO Expr instruction consumes 2 words of program memory while the
>BRA Expr instruction uses one word. This means that a GOTO table as
>shown above cannot work without some additional arithmetic on register
>W0. If the relative branch range of the BRA Expr instruction is
>sufficient for your needs, it should be used instead of GOTO.
>
>-- ScottG
>_______________________________________________
>Synth-diy mailing list
>Synth-diy at dropmix.xs4all.nl
>http://dropmix.xs4all.nl/mailman/listinfo/synth-diy
More information about the Synth-diy
mailing list