Discussion forum for the BasicX family of microcontroller chips.
Queues are our friend. They're great for moving data around efficiently. Do they only work for byte types? I can compile an application using integers in a queue array and I get no errors. Is this just an overly permissive compiler? I'm struggling to write a Kalman filter for ADC values (integers), and the FIFO queue would work perfectly to keep a running average. Feed the values in one end, calculate the average, then read the oldest value out and read the newest value in. It sure does eat up a bunch of RAM. I just don't know if it actually works though. I can't test it on real hardware at the moment. I'll know for sure tommorow when I can put a circuit together and see what happens. -Don
> ... I get no errors. All types are permissible since the source and destination parameters of GetQueue and PutQueue are pointers; that's where the bytewise transfer starts, but more than one variable can be moved in one function call. Working with integers just means you must put to, and get from the queue in pairs of bytes. You are responsible for specifying the byte count, in the case of a single integer, 2. If your filter buffer is 20 samples long, you'll need a queue of 40 bytes, plus nine bytes of overhead. Tom
Are sequential bytes possibly transmitted and received without pause? In other words,if you have SPI, I2C, or One-wire that requires a 16 bit word or longer - without pause; is it appropriate to use GetQueue and PutQueue? > > All types are permissible since the source and destination parameters of
> ... if you have SPI... is it appropriate to use GetQueue and PutQueue? PutQueue and GetQueue do RAM-to-RAM moves. In a sense, SPICmd() is similar except that it does RAM-to-I/O or vice versa. Both, however, require a starting RAM address and a byte count, so both can transfer more than one data item. Timing and shifting of SPI data is done within the SPICmd() function. I2C and 1-Wire shifting and timing is your responsibility. Jon Hylands' Dallas1Wire.Bas (in the Files section) routines will help, and there are several I2C implementations there, too. None use queues. Tom