So, what I'm I talking about?
- GD32F103x is running at 106Mhz and using DMA for SPI and is configured as a slave.
- PI Zero is a Master (maybe is using DMA transfers) SPI.
- SPI rate is 12Mhz (Close)
Channel 4 is the GD32F103 raising the pin high at the top of the loop and lowering the pin after the DMA is configured waiting on the PI.
Using top to monitor CPU usage on the PI Zero: spiExample, is taking 41% cpu usage (ouch).
Mem: 26956K used, 381340K free, 52K shrd, 1336K buff, 8332K cached
CPU: 0% usr 81% sys 0% nic 15% idle 0% io 0% irq 1% sirq
Load average: 1.41 0.80 0.61 1/97 247
PID PPID USER STAT VSZ %VSZ %CPU COMMAND
244 202 root R 3412 1% 41% ./spiExample
71 2 root SW 0 0% 10% [irq/56-dwc_otg]
73 2 root SW 0 0% 8% [irq/56-dwc_otg_]
130 2 root SW 0 0% 7% [spi0]
127 2 root SW 0 0% 6% [irq/44-DMA IRQ]
128 2 root SW 0 0% 5% [irq/45-DMA IRQ]
72 2 root SW 0 0% 5% [irq/56-dwc_otg_]
247 202 root R 2476 1% 1% top
3 2 root SW 0 0% 1% [ksoftirqd/0]
4 2 root SW 0 0% 0% [ktimersoftd/0]
84 2 root SW 0 0% 0% [irq/81-uart-pl0]
133 1 root S 20892 5% 0% /usr/sbin/vcfiled
148 1 root S 4144 1% 0% wpa_supplicant -B -i wlan0 -c /etc/wpa
202 1 root S 2476 1% 0% -sh
203 1 root S 2348 1% 0% /sbin/getty -L tty1 0 vt100
1 0 root S 2344 1% 0% init
99 1 root S 2344 1% 0% /sbin/syslogd -n
101 1 root S 2344 1% 0% /sbin/klogd -n
201 1 root S 2344 1% 0% udhcpc -i wlan0 -t 10 -b
124 1 root S 2208 1% 0% /usr/sbin/dropbear -R
Using top to monitor CPU usage on the PI Zero: spiExample, is taking 41% cpu usage (ouch).
Mem: 26956K used, 381340K free, 52K shrd, 1336K buff, 8332K cached
CPU: 0% usr 81% sys 0% nic 15% idle 0% io 0% irq 1% sirq
Load average: 1.41 0.80 0.61 1/97 247
PID PPID USER STAT VSZ %VSZ %CPU COMMAND
244 202 root R 3412 1% 41% ./spiExample
71 2 root SW 0 0% 10% [irq/56-dwc_otg]
73 2 root SW 0 0% 8% [irq/56-dwc_otg_]
130 2 root SW 0 0% 7% [spi0]
127 2 root SW 0 0% 6% [irq/44-DMA IRQ]
128 2 root SW 0 0% 5% [irq/45-DMA IRQ]
72 2 root SW 0 0% 5% [irq/56-dwc_otg_]
247 202 root R 2476 1% 1% top
3 2 root SW 0 0% 1% [ksoftirqd/0]
4 2 root SW 0 0% 0% [ktimersoftd/0]
84 2 root SW 0 0% 0% [irq/81-uart-pl0]
133 1 root S 20892 5% 0% /usr/sbin/vcfiled
148 1 root S 4144 1% 0% wpa_supplicant -B -i wlan0 -c /etc/wpa
202 1 root S 2476 1% 0% -sh
203 1 root S 2348 1% 0% /sbin/getty -L tty1 0 vt100
1 0 root S 2344 1% 0% init
99 1 root S 2344 1% 0% /sbin/syslogd -n
101 1 root S 2344 1% 0% /sbin/klogd -n
201 1 root S 2344 1% 0% udhcpc -i wlan0 -t 10 -b
124 1 root S 2208 1% 0% /usr/sbin/dropbear -R
Need to look into this:
- Is the Pi Zero using interrupts for SPI (according to /proc/interrupts) no, it is only using DMA
- Is it PREMPT_RT kernel?
- Doing some more testing it is setting a time between two back to back SPI packets. But, it only lowers the CPU to 18% on the PI Zero.
- The GDF32F103 only takes 62us to copy memory for slave and reload DMA buffers.
Well, next is to connect GPS, PWM (oneshot and decode) on the GD32F103.
Review, the GD32F103 is a I/O processor handling the following:
- PWM generation for the motors
- PWM/PPM decode RC transmitter
- I2C for LCD (Want to be able see status codes)
- (1) LED on the GD32F103 board for general status.
- RS232 GPS
- SPI slave device to the PI Zero
- The poll rate will be about 500hz
- PI zero is running BaseFlight/HackFlight.
Anyway, so, this week will be processing GPS,