Googling hasn't got me very far, but it seems it's quite easy in Atmel Studio C, for AVRs, for example - mostly, those are the results I get due to googles inability to stick to the point.
Today, I thought I'd write a quick test for a static RAM chip, since I recently bought some. It seems fairly obvious that the best way to do it would be to have an address bus on one port, a data bus on another, and then some control signals as single bits (just CS,WE and OE, in this case). I'm sure there are restrictions stopping me using certain bits, but in general, is that possible in Arduino on an STM32 Nucleo board?
In particular, I'm trying to do it with a Nucleo 64 STM32F446 board. If necessary, I could substitute an F103 or an F303 Nucleo 64, though it would seem any of those should be suitable.
Unless I'm reading it wrong, I seem to have one full 16 bit port, on PA0-15, and two ports with a bit missing from each, on PB and PC - there is no PB11 or PC10, unless I'm missing something.
For example, I'd like to be able to write something like this, to write a byte to the SRAM:
Code: Select all
void write_byte(unsigned int addr, uint8_t bval)
{
bset(OE,1); // Could assume these are already inactive...
bset(WE,1);
bset(CS,1);
pause(); // Ideally, I'd like _delay_us(0.125) (from AVR C), or similar, but I'll settle for delay 1us
PINA= addr; // This is the critical part - how can I do this, in STM32 Arduino?
PINB= bval;
pause; // pause a lot more than needed, to make sure
bset(CS,0); pause();
bset(WE,0); pause(); pause();
bset(WE,1);
bset(CS,1);
bset(OE,1);
}