Here is the problem (pays to make your own hg clone):
static int
_serial_getbyte(FILE *fp)
{
unsigned int rxmask = fp->drvarg[0];
unsigned int bitcycles = fp->drvarg[3];
...
}
static int _serial_fopen(FILE *fp, const char *name, const char *mode)
{
unsigned int baud = _baud;
unsigned int txpin = _txpin;
unsigned int rxpin = _rxpin;
unsigned int bitcycles;
...
bitcycles = _clkfreq / baud;
...
fp->drvarg[3] = bitcycles;
...
}
The number of cycles per bit is calculated based on the clock frequency when the file was opened. So for stdout, that would be in the startup code before my clkset call.
Thus if one wants to dynamically reset the clock rates, you need to also freopen the stdxxx handles of interest as well to capture the correct timings.
Victory!
All the best,
Tom
PS I got the multi-cog, interlocked SimpleSerial wrapper going. Works like a champ. I am now getting interleaved printf's from multiple cogs.
Comments
Uh-oh. Looks like I had a memory lapse. Ya, that should work as long as the clkset procedure in the data-sheet is followed.
Need more coffee
This is a better outcome than the alternatives which were either a muddled design or a supremely non-intuitive workaround for something
Cheers,
Tom
Here is the problem (pays to make your own hg clone):
The number of cycles per bit is calculated based on the clock frequency when the file was opened. So for stdout, that would be in the startup code before my clkset call.
Thus if one wants to dynamically reset the clock rates, you need to also freopen the stdxxx handles of interest as well to capture the correct timings.
Victory!
All the best,
Tom
PS I got the multi-cog, interlocked SimpleSerial wrapper going. Works like a champ. I am now getting interleaved printf's from multiple cogs.
Sounds like great progress.
Cheers.