It is now time to generate the code for the example we just created.
1. Select EmbCodeGen from the CodeGen menu.
2. A window appear, like the one in Figure 4.18. You can specify the directory where all the files will be created by modifying the Created files Path textbox. Please leave the other options unchanged.
3. Press Ok. As a result, a set of files are generated in the output directory.
4. Then, Scicos automatically opens a console window, running in it the following commands:
• the RT-Druid template generator to instantiate the Scicos template application;
• the RT-Druid standalone code generator to produce the Erika Enterprise Basic configuration files from the generated OIL file;
• the make application to compile the code.
5. The result of the code generation process. The executable file is named pic30.elf and it is located inside the Debug directory as usual for all
the Erika Enterprise Basic applications.
Figure 4.6: The LED block is dropped in the design window.
preference_pic30__use_evidence_compiler_4_deps = true
preference_pic30__use_evidence_compiler_4_compile = true
6. You can now program your application on your FLEX board. To do that, you need to open MPLABIDE as you usually do to program other Erika Enterprise Basic applications. Please refer to the Erika Enterprise Basic tutorial for dsPIC (R) DSC for more information.
Warning: If the ELF file fails to import on the MPLABIDE, try to use the C30 compiler recompiled from the Microchip sources by setting the following variables in the file c:/
preference_pic30__use_evidence_compiler_4_deps = true
preference_pic30__use_evidence_compiler_4_compile = true
7. Running the code on your FLEX board has the following behavior: the system led on the board flashes with a period of 20 seconds, and a duty cycle of around 6 seconds over 20. The explanation is the following:
• The system works like a synchronous control system, with a sampling frequency of 0.1s
• The Sine block output is a sinus with a frequency of 0.05, which correspond to a period of 20s.
• The LED block is directly linked to the system led, and is programmed to put on the system led when its input is greater than 0.5.
• It is clear that the sinus has a value greater than 0.5 for around a third of its period. Given that, the system led is on for around 6 seconds over 20.
|