Quantcast

MSP peripheral register dumper

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

MSP peripheral register dumper

Przemek Klosowski-2
I wrote a perl script that reads MSPGCC linker script defining
peripheral registers, and outputs a GDB function called 'mspview' that
dumps current peripheral register values for a particular MSP chip. I
use this script in a directory devoted to working on a project using a
specific chip:

 perl periphGDB.pl /usr/msp430/lib/ldscripts/msp430fr5969/periph.x > .gdbinit

Afterwards, GDB will pick up the function definition on startup;
invoking the command 'mspview' will display names and values of all
peripheral registers in this particular MSP chip. Hope it may be
useful to someone.

------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk
_______________________________________________
Mspgcc-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mspgcc-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: MSP peripheral register dumper

Michiel Konstapel-2
> I wrote a perl script that reads MSPGCC linker script defining
> peripheral registers, and outputs a GDB function called 'mspview' that
> dumps current peripheral register values for a particular MSP chip. I
> use this script in a directory devoted to working on a project using a
> specific chip:
>
>  perl periphGDB.pl /usr/msp430/lib/ldscripts/msp430fr5969/periph.x >
> .gdbinit
>
> Afterwards, GDB will pick up the function definition on startup;
> invoking the command 'mspview' will display names and values of all
> peripheral registers in this particular MSP chip. Hope it may be
> useful to someone.

That sounds very useful! Could you upload your script somewhere? I'm guessing you attached it to your message, but the mailing list stripped it off.

All the best,
Michiel
------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk
_______________________________________________
Mspgcc-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mspgcc-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: MSP peripheral register dumper

Przemek Klosowski-2
In reply to this post by Przemek Klosowski-2
I forgot that the attachments are stripped on the mailing list; here's
the script inline--hopefully it won't be botched by remailing. Try it
and if _this_ doesn't work I will put it on github soon.

#!/bin/perl
# Output GDB function dumping all peripheral registers; to be placed in .gdbinit
# Registers are shown as 2-byte hex values, so xxxx_H/_L definitions
are omitted.
# The definitions are derived from MSP430-GCC linker scripts e.g.
# /usr/msp430/lib/ldscripts/msp430fr5969/periph.x (format
__ADC12CTL0_L = 0x0800;)
($chipname) = ($ARGV[0] =~ m#(msp430[^/]*)/periph.x#);
while(<>){
    ($name,$addr) = /__(\w+)\s*=\s*(\w+);/;
    $daddr=hex($addr);
    ${$a2n{$daddr}}{$name}++;
    ${$n2a{$name}}{$daddr}++;
}
foreach $addr (sort {$a <=> $b} keys %a2n) {
    foreach $name (sort keys %{$a2n{$addr}}) { # we don't need  _L/_H
      delete ${$a2n{$addr}}{$name."_L"}   if (${$a2n{$addr}}{$name."_L"});
      delete ${$a2n{$addr+1}}{$name."_H"} if (${$a2n{$addr+1}}{$name."_H"});
    }
}
print "define mspview\n";
foreach $addr (sort {$a <=> $b} keys %a2n) {
    foreach $name (sort keys %{$a2n{$addr}}) {
      $format .= "\\n" unless $addr % 16; # occasional linebreaks
      $format .= "$name: %04x  ";
      push @vars, sprintf("*(unsigned short *)0x%x",$addr);
    }
}
print "printf \"Register dump for $chipname\\n$format\\n\", " .
join(", ",@vars) . "\nend\n";

On Wed, Nov 26, 2014 at 9:55 PM, Przemek Klosowski
<[hidden email]> wrote:

> I wrote a perl script that reads MSPGCC linker script defining
> peripheral registers, and outputs a GDB function called 'mspview' that
> dumps current peripheral register values for a particular MSP chip. I
> use this script in a directory devoted to working on a project using a
> specific chip:
>
>  perl periphGDB.pl /usr/msp430/lib/ldscripts/msp430fr5969/periph.x > .gdbinit
>
> Afterwards, GDB will pick up the function definition on startup;
> invoking the command 'mspview' will display names and values of all
> peripheral registers in this particular MSP chip. Hope it may be
> useful to someone.

------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk
_______________________________________________
Mspgcc-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mspgcc-users
Loading...