I am using a Raspberry Pi(Model 1 B+) and an oscilloscope in order to program SPI with C. I am doing this by using direct access to the GPIO register.
Like this: https://elinux.org/RPi_GPIO_Code_Samples#Direct_register_access.
The datasheet of BCM2835: https://www.raspberrypi.org/app/uploads/2012/02/BCM2835-ARM-Peripherals.pdf
The problem is that if I do access the register using a bitwise operation as following :
GPSET0 |= 1 << 8;
it also modifies the GPIO pin 11. I think I heard some of GPIO pins are hard-wired together. Is it because of that?
But if I don't use bitwise operation, i.e:
GPSET0 = 1 << 8
It only modifies the GPIO pin 8.
I need advice. Thank you.
P.P.S This is how I initialised GPSET0 and gpiomem is the pointer stored after mapping the memory.
#define GPFSEL0 gpiomem[0]
#define GPFSEL1 gpiomem[1]
#define GPFSEL2 gpiomem[2]
#define GPFSEL3 gpiomem[3]
#define GPSET0 gpiomem[7]
#define GPSET1 gpiomem[8]
#define GPCLR0 gpiomem[10]
#define GPCLR1 gpiomem[11]
#define GPLEV0 gpiomem[13]
#define GPLEV1 gpiomem[14]
#define SEL_FNC(gpfsel, pin, fnc) gpfsel = (gpfsel & (~((0x7)<<(pin*3)))) | (fnc << (pin * 3))
#define SEL_OUTPUT 0x1
#define SEL_INPUT 0x0
extern volatile uint32_t *gpiomem;
P.S.
While the SPI library offered is precise, it seems rather slow because of the delay between the chip select and the data transmission. a few tens of micro-seconds. (To be precise 33.6us but this doesn't work for me because I need to refresh a 128x160 LCD module using ST7735. Taking account of this alone gives me a calculation of 600ms to refresh a screen, approximately) There is a bit longer delay until next transmission.
Maybe I am doing this wrong. If someone can give me an insight into this, that'd be great.