Examine processor registers and variables from PC?

For questions and comments on programming in general. And for any items that don't fit into the forums below.

Moderators: Benj, Mods

Post Reply
PicoPuls
Posts: 111
Joined: Wed Mar 02, 2016 11:26 am
Has thanked: 43 times
Been thanked: 22 times

Examine processor registers and variables from PC?

Post by PicoPuls »

Would it be possible to write a variable name on HyperTerminal on PC ( example "xVariable")
and have the value in return (example 1011) ?

The only thing needed is a function Execute(cIN) where cIN is the string "xVariable"
and where the return value is the value of the variable or register.

As a PC is powerful and easy to program
this would be a great way to overview internal variables and registers of a processor.

The UART is easy to establish with an USB cable

Best regards
BO
Attachments
Variable_Via_UART.jpg
Variable_Via_UART.jpg (35.92 KiB) Viewed 6086 times

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Examine processor registers and variables from PC?

Post by Benj »

Hello,

We have done a similar thing before for reading/writing registers and global variables e.g. ICD, however we have to use the addresses of the register/variable and not the name.

The name of the variable/register is a thing that only exists before compilation. After compilation the name or reference to the object essentially shifts to become an address.

So you might do something like this to write a byte to a register/variable.

Code: Select all

add_lsb = receiveByte
add_msb = receiveByte
value = receiveByte
address = (add_msb << 8) | add_lsb
&address = value
And you might do something like this to read a byte from a register/variable.

Code: Select all

add_lsb = receiveByte
add_msb = receiveByte
address = (add_msb << 8) | add_lsb
value = &address
transmitByte value
The .cof file contains the addresses of your programs global variables but can be tricky to decode.

The easier way but less universal is to interpret the address yourself. e.g. use a switch icon and have your own breakdown of value to variable.

Code: Select all

address  = receiveByte
value = receiveByte
switch (address)
{
case 0: 
   var_0 = value
   break
case 1: 
   var_1 = value
   break
case 2: 
   var_2 = value
   break
}

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times

Re: Examine processor registers and variables from PC?

Post by QMESAR »

Benj wrote: We have done a similar thing before for reading/writing registers and global variables e.g. ICD,
I believe you Ben :D we all did but that was the time before we had ICD's ,today it only make sense to do this if you are exporting real time data to an PC GUI but for debugging there are much more reliable tools from MATRIX and the Chip manufacturer :D

PicoPuls
Posts: 111
Joined: Wed Mar 02, 2016 11:26 am
Has thanked: 43 times
Been thanked: 22 times

Re: Examine processor registers and variables from PC?

Post by PicoPuls »

Thanks Benj,
This is very interesting because I am up to importing and exporting
real time data to an PC GUI. I have long experience in windows database programming but I am a beginner in processors.

This is my challenge on the processor side:

A string is given from the outside world with 16 analog values, each 16 bit
That is 32 bytes in total.
This string might look like this in an ascii editor

cSTR= "Gl║D╬õA#;?OW,│Hð£öµ8jXdR±6aAý¤K1"

I am searching the most efficient flowcode approach to handle these 16 values in compare situations,

In a PC language you could define a function nVal()
or whatever you might call it
that extracts for example
the 4-d value from cStr (the red two bytes above in the example string)

IF nVal(cSTR,4) > 62000
Do something
ENDIF


What would these lines look like in Flowcode7 ?

As there will be about 100 such compare operations in a very fast loop
it is important to find efficient code.

On the other hand,
as dsPIC33EP512 is fast, it might even be enough to use the most simple flowcode approach.


Thanks and Best regards
BO

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times

Re: Examine processor registers and variables from PC?

Post by LeighM »

Try something like this ...
int_array.jpg
int_array.jpg (25.04 KiB) Viewed 6057 times

medelec35
Matrix Staff
Posts: 9521
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times

Re: Examine processor registers and variables from PC?

Post by medelec35 »

Hi BO,
Attached is a flowchart I developed for 8 bit pics, but I'm sure it could easily be adapted for your device.
You can enter in a a label for the register and add a register name within C code.
Then the binary value is sent via RS232.
It can send 8 or 16bit binary values.

Martin
Attachments
Display REG in Binary.fcfx
(10.74 KiB) Downloaded 338 times
Martin

Post Reply