I'm trying to find an Arduino (AVR-based) that exposes a complete 8-bit port without masking anything else critical. I want to be able to output 8 bits of data in parallel, rapidly, through a port write. But can't find a board that does it.
The Uno exposes port D, but that interferes with the UART. The Leonardo exposes port C, but that's also the hardware SPI pins(it also exposes D, but same problem with UART). Looks like the mini exposes port C, but the mini is kind of annoying to use....
So is there such a creature?
If arduino mega isn't too big for the application, you have more chances to find complete port.
exposes a complete 8-bit port without masking anything else critical.
Please list the things you consider "critical"? SPI, UART... What else?
It's a little hard to fit only the standard Uno pinout.
MEGA exposes PK and PF (conflicts with analog), and it looks like PA, PC, and PL. Maybe some others, if you re-gather the pins that have been arranged "by function" instead of "by port."
http://www.badnetwork.co.uk/ArduinoForum/arduino-mega-2560-pin-out.png
exposes a complete 8-bit port without masking anything else critical.
Please list the things you consider "critical"? SPI, UART... What else?
UART, SPI, I2C. Reset pin. I don't need to protect ADC or PWM pins for this, they are fine being utilized.
I hadn't considered the Mega - forgot it exists, since I never use them. Might work. Size is not so much of an issue, right now I'm just prototyping ideas, if the project works the final version would have an AVR chip directly on the final pcb anyway.
Why do you need to write 8 bits in parallel, how fast is 'rapidly', and why must it be an Arduino?
Why do you need to write 8 bits in parallel, how fast is 'rapidly', and why must it be an Arduino?
Why Arduino? Because it's a platform I know and can write the code I need without going out and learning another system.
The 8 bits would feed an R2R ladder to generate an audio tone. How fast? I want to generate sine waves of up to about 2200Hz frequency. I've not tested it, but I suspect that grabbing 8 random pins and doing digital writes to them wouldn't be fast enough (nor simultaneous enough).
Why 8 bit? I'm guessing that that's the lowest resolution that'll work. Most people doing this task use 10 or 12 bit DACs. I want to see if an 8 bit ladder (with an output low pass filter) would produce a tone acceptable for the task.
The tone doesn't need to be perfectly pure, some, but not too much, distortion is ok, but I don't know how much. The tone would be used for AFSK modulation of a radio transmitter, and the digital signal would need to be decorate by the reciever. The only way I can think of to determine if this is good enough is to try it.
What about stm32f103 blue pill and stm32duino?
Why Arduino? Because it's a platform I know and can write the code I need without going out and learning another system.
The 8 bits would feed an R2R ladder to generate an audio tone. How fast? I want to generate sine waves of up to about 2200Hz frequency.
For that I would use PWM, then you only need 1 pin and a simple low-pass filter:-
Fast 8/10-bit PWM DAC for the Arduino I've not tested it, but I suspect that grabbing 8 random pins and doing digital writes to them wouldn't be fast enough (nor simultaneous enough).
With efficient coding the outputs could be synchronized to within 62.5ns (1 CPU cycle at 16MHz).
Why 8 bit? I'm guessing that that's the lowest resolution that'll work. Most people doing this task use 10 or 12 bit DACs. I want to see if an 8 bit ladder (with an output low pass filter) would produce a tone acceptable for the task.
It should be fine. Even 1 bit (square waves) should work with a good low-pass filter (for 1200/2400Hz FSK it would need to pass 2400Hz and block 3600Hz).
If you are generating audio, in most cases the STM32 SPI peripheral can be put into I2S mode and you just connect a I2S DAC, like CS4334, on it.
You can use direct port manipulation with the Arduino. It is much faster than doing a digital write to a specific pin. You should be able to get the speed you need by using two different ports to get the amount of GPIO you need.
Direct port manipulation was exactly the plan, but I hadn't considered using two ports - that should work, and is easy to try.
I considered PWM, but most of what I've read suggests even filtered it's a really rough waveform. May try it anyway at some point.
Using an external DAC is easy, but I wanted to see if I could do this without one.
You can use direct port manipulation with the Arduino. It is much faster than doing a digital write to a specific pin. You should be able to get the speed you need by using two different ports to get the amount of GPIO you need.
Direct port manipulation was exactly the plan, but I hadn't considered using two ports - that should work, and is easy to try.
I considered PWM, but most of what I've read suggests even filtered it's a really rough waveform. May try it anyway at some point.
Using an external DAC is easy, but I wanted to see if I could do this without one.
Arduino Due, the one that came with ATSAM3X8E, have built-in DACs. So does some of the STM32 chips.
Due maybe OK for your, and do not use the packaged Arduino commands? the ports commands would be much quicker.
the ports commands would be much quicker.
yeah, but it's still pretty much a pain in the neck to take your byte-wide quantity and shift it around/etc so that you can output the low 6 bits on the upper 6 bits of portD and the high two bits on the lower two bits of portB (or equiv.)
Due has the ARM processor, and I'd rather stay away from that, for a number of reasons. Id prefer to do this with an 8-bit AVR.
the ports commands would be much quicker.
yeah, but it's still pretty much a pain in the neck to take your byte-wide quantity and shift it around/etc so that you can output the low 6 bits on the upper 6 bits of portD and the high two bits on the lower two bits of portB (or equiv.)
Due has the ARM processor, and I'd rather stay away from that, for a number of reasons. Id prefer to do this with an 8-bit AVR.
What I was saying is that you can make use of the internal DAC of the Due.
Yes, or use an external i2c or SPI DAC with an Uno. But I want to see if I can make it work with an r2r ladder.
Yes, or use an external i2c or SPI DAC with an Uno. But I want to see if I can make it work with an r2r ladder.
R-2R ladder uses a lot of high precision resistors. Are you okay with the cost of the precision resistors here? Chips also uses R-2R but those are laser trimmed.
Yes, or use an external i2c or SPI DAC with an Uno. But I want to see if I can make it work with an r2r ladder.
R-2R ladder uses a lot of high precision resistors. Are you okay with the cost of the precision resistors here? Chips also uses R-2R but those are laser trimmed.
I'll start with 1% and see how that goes. The idea is to throw together something quick and dirty, see if it works, then refine from there. Or give it up and go a more conventional route.
I hadn't considered the Mega - forgot it exists, since I never use them. Might work. Size is not so much of an issue, right now I'm just prototyping ideas, if the project works the final version would have an AVR chip directly on the final pcb anyway.
The Mega has four ports that seem to meet your specifications, with A and C being the most obvious, since their alternate function is an external memory interface. The other two are F and K, which overlay the ADC inputs.
Yes, or use an external i2c or SPI DAC with an Uno. But I want to see if I can make it work with an r2r ladder.
R-2R ladder uses a lot of high precision resistors. Are you okay with the cost of the precision resistors here? Chips also uses R-2R but those are laser trimmed.
I'll start with 1% and see how that goes. The idea is to throw together something quick and dirty, see if it works, then refine from there. Or give it up and go a more conventional route.
It may be better to use an DAC0832 and strap the pins into the straight-through mode. That way you get almost the save driver code as R-2R and laser-trimmed precision resistors as used in an IC.
Since the OP wants to connect an R-2R resistor DAC directly to the ports there will always be a glitch (and possibly quite a large glitch) if it has to be updated with two consecutive write operations.
One port can supply the upper 6 bits, then the largest glitch is 1.6% of full scale for 62.5ns. After low-pass filtering I bet this will be virtually undetectable.
Why Arduino? Because it's a platform I know and can write the code I need without going out and learning another system.
You don't learn the platform. You learn principles. Then you can move from platform to platform rather easily. There are plenty of MCUs with built-in DACs. It is wise to choose one of them unless you want an exercise in using parallel ports.