May 18, 2015

Time lapse of clouds in a sunny day

Some days clouds just look amazing, and in such a day it is so difficult not to photograph them. However this time I shoot about 1400 photos in about 1.25 hour to see how beautiful they move, change their shape and dissipate.

May 12, 2015

How to log debug data in TI CCS?

* This topic is based on experience with Texas Instruments (TI) Code Composer Studio (CCS) version 5.5


Let's say we have pressed the green bug button in order to debug our project when it is running on a target device. We add some variables of our interest, e.g. temperature sensors, to the CCS' Expressions view for watching them during the debug session. Here, assume we only use JTAG. What if we want to log these data in a file for analyzing it in a later time? Obviously to halt the program and do a copy and paste from the Expressions view to a text file manually is a burden! Good news is that there is a better way to do this, and the key is to use Scripting Console within CCS. To see the Scripting Console view follow this menu steps: "Window -> Show View -> Scripting Console". Let's denote Scripting Console by SC in the rest of this text.

Scripting Console in CCS v5.5


The scripting language of SC is JavaScript. To see the already existing functions and definitions in SC press the "Tab" button. To view help for each of the listed items type "help item_name". To serve our logging purpose the "saveData" command is the right tool for us. Let's see the help for it: 

 js:> help saveData
                                                                                  
Description: Save a block of target memory to a data file format
Syntax: saveData(address,page,filename,length,IOFormat,append)
Arguments: 
  address - the first address in the block
  page - the memory page, use one of the PAGE_X constant
  filename - specifies the name of the file that store the target data
  length - defines the number of words to store
  IOFormat - Specifies the format in which memory words will be written to the output file. Use one of the IOMEMORY_X constant
  append - true to append to an existing file, false to overwrite. Note: append is not supported for COFF formatted files.
  
 It is pretty clear what to do now. So if we stick to our example of logging temperature sensors we need to know where in memory these values exist. If the variables are in a structure and we add that structure to the Expressions view, the address of that structure is already shown under the Value column. Another way to find the address for any variable is to right click on its name in the Expressions view and select "View Memory", and voila!, you find the address highlighted in the left column, e.g. something like 0x0000BA10. Note that if you change your code which manipulates data storage, then you want to check the addresses again.

 Next in the line is 'page', and in our example we need PAGE_DATA, which is a predefined variable in the SC, just it. Then the filename is where the log file is stored. We have to give the filename as string and note that a windows path like "C:\MyProjects\hemnik\logs\temp.log" will not work, because \ (backslash) is used as escape notation in JavaScript which is used to encode special characters. Find more about JavaScript string here, and if you want to know moew about JavaScript here is a great reference. So to make this path work we need to support each \ with another \ and our example path becomes "C:\\MyProjects\\hemnik\\logs\\temp.log". Remember to keep the quotes around the string, both single or double quotes work.

 The length is dependent on the number of variables we want to store at once, let's say we have 3 temperature sensors, so we write 3. We choose IOFormat based on the data type. If we want to log data as a float value we use IOMEMORY_FLOAT, if integer we choose IOMEMORY_INT and like that. Take care about the length and IOFormat, they are interrelated. The last parameter, append, is a Boolean and based on our need we choose either true or false. All said, let's see the example command in one line:

 js:> saveData(0x0000BA10, PAGE_DATA, "C:\\MyProjects\\hemnik\\logs\\temp.log", 3, IOMEMORY_FLOAT, false)

 Press enter, and we get an error that says 'Could not open file', so we need to make the file before running the command. Now it works and we are done with the basic logging! But still it is not convenient to type this command for different variables and in different times one by one in the SC. A better choice is to use "loadJSFile" command in SC: 

 js:> help loadJSFile                                                                               
Description: Load a JavaScript file or all the JavaScript files in the directory. Example: loadJSFile c:\myDirectory\myJavaScript.js
Syntax: loadJSFile(file,store)
Arguments: 
  file - the JavaScript file or a directory.
  store - [optional] true, store the file(s) to the preference, the script will auto reload the next time the view is open.
  
This is our key to a better automated logging process. We write all the desired logging commands in a JavaScript file and only by loading that file in SC all the logging process is done. This way, we can write logging commands for any number of variables we need at different memory locations with different IOFormats only once and in one file. Another great possibility is that we can even include the whole process of starting the debug session and running the code on the target in our script and control the steps. Let's see all these in a simple example script, e.g. saved as C:\MyProjects\hemnik\ccs_run_test_log.js:


Then we only need to run this script in SC as following:

js:> loadJSFile C:\MyProjects\hemnik\ccs_run_test_log.js

That's it! Good luck with your projects.

Mar 18, 2015

Tronheim's smoking

A strong northern lights, Aurora Borealis, happened over Trondheim, and it was amazing, all around and moving fast. It was so beautiful.


Feb 28, 2015

11 p.m. Trondheim

Days are getting longer here and I am waiting for the beautiful long summer days. Look at this sunset at 11p.m. from before. Norway's summers are charming.

Feb 24, 2015

All sharpened

I have sharpened some colour pencils for my children and collected the pencil shavings in a glass. I started taking some macro shots where I broke the glass in the process and it become sharp same as the pencils ;) And all that resulted in this shot.

Update: Now I enjoy this as my desktop background :-) 

Jan 26, 2015

River's eye

Photographing direct sun is a lot of fun and it is normally challenging. Here is a shot from a beautiful summer midnight sunset in Trondheim. The sun inside the bridge's curve and the reflection resemble an eye. 

Jan 21, 2015

Cloud fetus in flower bed

I was shooting these beautiful flowers over my head where I noticed that cloud, looking like a baby fetus. Then I framed it as well as I could to fit it in the flowers curve, forming a bed.

Jan 18, 2015

Run towards the sun

Let's see a warm sunny photo after seeing several cold winter photos :)
Yes there is someone running on the beach towards the sun, maybe she can catch the sun before it is totally down.

Jan 17, 2015

Tusen takk! / Most shared topic about Norway ...

Tusen takk alle!
Thank you very much everyone! 
I have found that the news article that is featuring one of my photos, has been the most shared topic about Norway on the social networks today and up to the now that I am writing this post. The statistics is live on http://storyboard.mx/norway/ , since when you read this post there might be other statistics, I took a photo from the page right now. To make it clear, "Storyboard is an analysis service for journalists, editors and media analysts, who provide insight into the use of social media in Norwegian online newspapers."
Thanks to all of you, and @NorunnBergesen (twitter) and adressa.no !


Jan 15, 2015

My photo and an interview with me in the local news on adressa.no :)

Full story (in Norwegian): Nidelven fosser over - på Twitter -adressa.no
Bildet til Hessam Mossavinik, Trondheim night in winter (2nd edition), deles heftig på Twitter i kveld. Foto: Hessam Moussavinik
Bildet til Hessam Mossavinik, Trondheim night in winter (2nd edition), deles heftig på Twitter i kveld. Foto: Hessam Moussavinik
Nidelven fosser over - på Twitter
Bildet viser Trondheim i vinterskrud og er gull verdt for oppmerksomheten om byen.