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
Examine processor registers and variables from PC?
- 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?
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.
And you might do something like this to read a byte from a register/variable.
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.
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
Code: Select all
add_lsb = receiveByte
add_msb = receiveByte
address = (add_msb << 8) | add_lsb
value = &address
transmitByte value
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
}
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
- QMESAR
- 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?
I believe you BenBenj wrote: We have done a similar thing before for reading/writing registers and global variables e.g. ICD,


https://www.flowcodexchange.com/
Regards QMESAR
Regards QMESAR
Re: Examine processor registers and variables from PC?
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
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
-
- 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?
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
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