Hi,
I'm working on a project where I would like to send a string x times per second, while still maintaining a stable main loop.
Currently I am running the main loop at 1000Hz, and sending a string at 1Hz by using interrupts:
 
#define SLOWFREQ 1
#define FASTFREQ 1000
Ticker SlowTick, FastTick;
MODSERIAL pc(USBTX, USBRX, 512); //512B buffer
int SlowTicker, FastTicker;
void SlowTickFunction(){
    SlowTicker=1;
}
void FastTickFunction(){
    FastTicker=1;
}
int main() {
    SlowTick.attach_us(&SlowTickFunction, 1000000/SLOWFREQ);
    FastTick.attach_us(&FastTickFunction, 1000000/FASTFREQ);
    pc.baud(115200);
    
    while(1) {
        if(FastTicker==1){ //running at FASTFREQ Hz
            FastTicker=0
            //doing some tasks
        }
        if(SlowTicker==1){ //running at SLOWFREQ Hz
            SlowTicker=0
            pc.printf("V1: %f, V2: %f, V3: %f, V4: %d V5: %f, \r\n", Var1, Var2, Var3, Var4, Var5); //printing some variables
        }
    }
}
Is this how you would send data to the computer if you just wanted to view it in the terminal? Any tips or clues to do this better\smarter? 
Say I later want to compress the data output by only sending the necessary few bits for each variable to a self written application on my computer that interprets it and presents the data to me, would I still use this technique? I've seen people mention that one should only use putc because it's less resource-demanding, but I'm having trouble seeing how this would be implemented.
Lastly, a question regarding the modserial-library. Have I understood it correctly when I am assuming that "fully buffered input/output" means that when I use modserials printf-function it will immediately send it to a buffer, which in turn will send the data when the micro controller has available resources? Because when I use the standard serial library and I send a long string, I notice a "break", which I assume is the micro controller sending the data and "pauses" everything else until the data has been sent, which speed is set by the baud rate. I can't seem to notice this break when using the modserial-library.
This would of course be devastating for a project like mine that demands a stable high frequency looping function. 
                    
                 
                
             
        
Hi,
I'm working on a project where I would like to send a string x times per second, while still maintaining a stable main loop.
Currently I am running the main loop at 1000Hz, and sending a string at 1Hz by using interrupts:
#define SLOWFREQ 1 #define FASTFREQ 1000 Ticker SlowTick, FastTick; MODSERIAL pc(USBTX, USBRX, 512); //512B buffer int SlowTicker, FastTicker; void SlowTickFunction(){ SlowTicker=1; } void FastTickFunction(){ FastTicker=1; } int main() { SlowTick.attach_us(&SlowTickFunction, 1000000/SLOWFREQ); FastTick.attach_us(&FastTickFunction, 1000000/FASTFREQ); pc.baud(115200); while(1) { if(FastTicker==1){ //running at FASTFREQ Hz FastTicker=0 //doing some tasks } if(SlowTicker==1){ //running at SLOWFREQ Hz SlowTicker=0 pc.printf("V1: %f, V2: %f, V3: %f, V4: %d V5: %f, \r\n", Var1, Var2, Var3, Var4, Var5); //printing some variables } } }Is this how you would send data to the computer if you just wanted to view it in the terminal? Any tips or clues to do this better\smarter?
Say I later want to compress the data output by only sending the necessary few bits for each variable to a self written application on my computer that interprets it and presents the data to me, would I still use this technique? I've seen people mention that one should only use putc because it's less resource-demanding, but I'm having trouble seeing how this would be implemented.
Lastly, a question regarding the modserial-library. Have I understood it correctly when I am assuming that "fully buffered input/output" means that when I use modserials printf-function it will immediately send it to a buffer, which in turn will send the data when the micro controller has available resources? Because when I use the standard serial library and I send a long string, I notice a "break", which I assume is the micro controller sending the data and "pauses" everything else until the data has been sent, which speed is set by the baud rate. I can't seem to notice this break when using the modserial-library. This would of course be devastating for a project like mine that demands a stable high frequency looping function.