Monday, 13 November 2017

TMS570 FreeRTOS Tutorials



Tutorials for the Hercules TMS570 with FreeRTOS.

https://www.youtube.com/playlist?list=PLOm_uByvxrU7no0Q2WWiPv-__gbYWUNp1

Nucleo STM32 FreeRTOS Notifications

Requires previous post.


Lets use FreeRTOS notifications to blink LEDs on the nucleo board.  FreeRTOS notifications are a fast way to signal other tasks and to provide other tasks with data.


First create a new task.






Check if notifications are enabled.



Save and generate new code.

Start OpenSTM32.


Modify the default task. If the default task receives 'Q' from UART then the second task will be sent a value of 42.

If the default task receives 'V' from UART then the second task will be sent a value of 1.



Modify the Task02. If the task02 receives 42 from the default task then the LED will be turned on.

If the task02 receives 1 from the default task then the LED will be turned off.




Sending commands from UART.

Turn LED on.


echo "Q" > /dev/ttyACM0


Turn LED off.


echo "V" > /dev/ttyACM0


Any other character does nothing to the state of the LED.











Sunday, 12 November 2017

Nucleo STM32 FreeRTOS Timers

Requires previous post.

To create timers enable the use of timers in the FreeRTOS config.




Add a timer in Timers and Semaphores.





Now generate the code and start OpenSTM32.


To use any timer,you first need to set the timer's periods.

Here the timer is set to expire every 1000 ticks.

xTimerChangePeriod(myTimer01Handle,(TickType_t) 1000, (TickType_t) 10);

When the timer is created, it does not start automatically. Use xTimerStart to start timer.

xTimerStart(myTimer01Handle,(TickType_t) 10);


Modify the default task.


Change the timer callback. The callback will send data to the task.


Now run it.







Nucleo STM32 FreeRTOS Receive UART Using Queues

Requires previous post.

Receiving data from UART using a queue. The UART will be configured to have interrupts. When the interrupt happens then a character will be received and be sent to a queue. A task will then process the queue's information. After that, the task will transmit data back to UART.



Select the configuration tab.



Click UART2. Go to NVIC and enable the UART2 Interrupt.



Create a queue in the FreeRTOS selection. The queue will be used to store data.





Now generate the code and start OpenSTM32.

Create this new function in main.c


And this to the default task in main.c .




Now run the code.

Send some data to the STM32.

echo "Hello World!" >  /dev/ttyACM0





Nucleo STM32 FreeRTOS UART Virtual COM port

This tutorial will show you how to create a Nucleo STM32 UART communications in FreeRTOS. Nucleo STM32 UART communicates with a computer using a virtual COM port. This allows printing in a terminal for debugging in FreeRTOS.


First select the nucleo board.



Enable FreeRTOS.


Select one of the timers as timebase source for FreeRTOS.





Enable UART2. This UART communicates with STLink and the virtual COM port on the computer.



In Project->Settings
Select SW4STM32 IDE




Project->Generate Code



Open OpenSTM32 IDE and import the project.











Open Src->main.c

Add the code to the StartDefaultTask.






Hit the compile button.



Select Debug Configurations.




Add a new debug configuration under Ac6 STM32 debugging.




Click Debug button on the bottom right.

It should open this window.

Then click resume button.



The STM32 code will be running.

After that, open a virtual COM port.

I like to use picocom to view the virtual COM port. The default baudrate is 115200.

picocom -b 115200 /dev/ttyACM0



The code will print "HI" to the terminal.






Thursday, 13 July 2017

Xilinx SDK

Xilinx SDK has many bugs since it uses eclipse.


If Xilinx SDK fails to open. Delete the .metadata folder and try again.


To program the bit stream use Xilinx Tools -> Program FPGA

To program microblaze right click Run as-> Launch on Hardware (System Debugger)

Monday, 30 January 2017

Raspberry PI Bluetooth PAN (JAN 2017)

Requires:

  • BlueZ 5+
  • Python2.7
  • bt-pan
  • bridge-utils
Get bt-pan here

or

wget https://raw.githubusercontent.com/mk-fg/fgtk/master/bt-pan


Load bluetooth on both devices


systemctl start bluetooth

On the Raspberry Pi


1) Pair devices with bluetoothctl or GUIs

2) Execute this script

brctl addbr pan0
brctl setfd pan0 0
brctl stp pan0 off
ip addr add 10.1.2.3/24 dev pan0
ip link set pan0 up
python2.7 bt-pan --debug server pan0


This will setup the Raspberry Pi to have an IP of 10.1.2.3 and netmask of 255.255.255.0 .

3) If it works then create a systemd service


On client


1) Pair devices with bluetoothctl or GUIs


2) Execute


python2.7 bt-pan --debug client XX:XX:XX:XX:XX:XX --wait



3) If it works then create a systemd service



4) Configure the client IP to be 10.1.2.2 . Netmask is 255.255.255.0 . Gateway is 10.1.2.0 .




Friday, 27 January 2017

How to deploy MATLAB/Simulink on Raspberry PI without reformating SD Card

First install the Simulink support package for Raspberry Pi or MATLAB support package for Raspberry Pi.

Easy way. Type in 


raspi.internal.firmware.setupMATLABServer('<IP address>','<User name>','<Password>')

This should setup everything if it succeeds to execute the script. The user need root privileges and sudo without asking for the password.







If all fails.



Type in  

targetupdater

in MATLAB and configure the settings.

MATLAB will download a file called raspberrypi_firmware_16_2_0.zip.

Unzip it and open the image file.

Copy the entire /opt to your existing installation.

The location /opt/MATLAB/server_v16.2.0/ is where the binaries live.





To start MATLAB run

sudo /opt/MATLAB/server_v16.2.0/matlabd   <PORT NUMBER>

The port number is usually   18732   or the one you set.






To start the UDP daemon run


/opt/MATLAB/udp_ip /boot/iflist.txt


After this MATLAB/Simulink should work.