assign functions to cogs?
p02osmaj
Posts: 14
Hello everyone!
How can I assign funcitions/tasks to one cog?
How can I assign funcitions/tasks to one cog?
Comments
Have you looked at the LMM C toggle example?
PropGCC cogstart: https://sites.google.com/site/propellergcc/documentation/libraries/propeller-h-library#TOC-cogstart
Tutorial: http://learn.parallax.com/propeller-c-functions/multicore-example
We are adding a simpler approach to the simpletools library as well. I'll have a series of short tutorials available for it sometime next week, and will post here when it is ready.
I have written this code and gime a lot of errors the SimpleIde. I don't know is because the simplei2c.h ...
thank u!
#include "simpletools.h"
#include "simplei2c.h"
#define numero_servos 3
i2c *i2c_pointer;
void funcion_expansores (void);
int main(void)
{
i2c *i2c_storage;
i2c_pointer = i2c_open(i2c_storage, 37, 38, 0);
int pin = 16;
int stacksize = sizeof(_thread_state_t)+sizeof(int)*25;
int *stack = (int*) malloc(stacksize);
int cog;
// initialize wait time to 50ms
wait_time = CLKFREQ/20;
// start the cog
cog = cogstart(funcion_expansores, (void*) pin, stack, stacksize);
funcion_expansores();
return 0;
}
//Se asigna un cog a esta funcion
void funcion_expansores (void) {
/*Se declara un array de enteros donde se almacenaran los bytes de cada expansor*/
unsigned int byte_expansor[numero_servos];
/*Se declara un array de enteros que se usa para indicar si ha habido cambios en los byte de los expansores*/
unsigned int cambio_byte[numero_servos];
/*Se declara un array de enteros donde guardar si ha habido una "interrupcion" en el expansor y hay que leer
de este. IMPORTANTE: esta se
We posted the Multicore Approaches tutorial here: http://learn.parallax.com/multicore-approaches
This tutorial uses newly-released libraries, so you must update your Learn folder: http://learn.parallax.com/propeller-c-set-simpleide/update-your-learn-folder
why the compiler continue give me errors even in parts of code that are commented: /*....*/ ??
In SimpleIDE?
It is an unintended consequence sometimes of not knowing where the error is (like a linker error). This annoys me too and should be fixed.
BTW, just for context the IDE is not the compiler. It simply tries to interpret the compiler and other program results.
Sorry for the trouble.
and are there examples of the use of simplei2c.h?
Thank you all
Check the build status window. It gives all details of building.
All SimpleIDE learn libraries have test code in them. The libsimplei2c has most of it's test code commented out, but you should be able to use the examples there to learn more about the library. I strongly recommend reading the documentation for the library also. Documentation is in your Documents/SimpleIDE/Learn/Simple Libraries Index.html or on line here.
Also, the simpletools library has some eeprom code that uses simplei2c.h.
I have this problem. I want to pass a parameter to a function through the function cogstart, and it's a struct parameter.
Is is could be possible pass a struct parameter?
if so, how can I do it?
Thank you!
I have solved one error, but I can't with this. I copy only the important part of code the error is exactly this:
Here is your code, adjusted to compile:
P.S. I cannot vouch for runtime errors, but it appears to be free of compiler errors.
I have a different error, that appear me in this type functions declarations instructions:
I don't know if it's because the "&" or what else...?
the part of code of this is the following:
Thank you Andy
I don't know if you understood that I want.
I have write a code more clear and clean with the same idea.
This code does work in other compiler but doesn't work with the SimpleIde Compiler
I have tried with "*" too
Note: the "&" operator is only valid in C++. Either rename your source file from something.c to something.cpp, or use the "*" operator instead of the "&" operator to make the error go away.
===Jac
To clarify ....
The & operator in a function signature variable declaration is not valid in C. The pointer * operator should be used instead.
somefunction(int *var); // valid in C/C++ ... specifies the type is a pointer (address of a variable passed to function).
somefunction(int &var); // valid only in C++ ... specifies the type is a reference (alias of a variable passed to function).
When calling somefunction(int *var) ... the & can used by the caller to say use address of variable (pointer to variable).
For C:
void somefunction(int *var)
{
}
int myvar = 0;
somefunction(&myvar);
For C++:
void somefunction(int *var)
{
}
void somefunction(int &var)
{
}
int myvar = 0;
somefunction(&myvar);
somefunction(myvar);
P.S. In Propeller C, you can reduce the size of a program that displays floating point values by using print instead of printf.