Saturday, February 22, 2014

Lilttle narrow one for the stm32f313v flight controller(V2)

This may be the last Eagle version for the controller. I do not think I did care more about the trace smoothness when I was layoutting, but it probably fitted there.
I deleted some useless thing such as the RTC emergency ridiculous battery instant substitutional voltage source. And of course I delete the big switch and reverse plug protection components and traces. I don't know. It probably the most useless part I 've ever seen.



                                       
GY-86 is probably not best choice but it is still a good choice. If you have ever seen the guy in the web using the Eight bit PIC and a IMU as a combination component. You will know that it is better that use a 8 bit microcontroller  to separate the task efficiently. I will  not do that because I am doing just a simple flight controller. It is enough to solve problems now by using just one 32 bit MCU.






Thursday, February 20, 2014

2 layer Eagle PCB for STM32F3 version Flight Controller

As soon as I am concerned, eagle PCB is a very good tool of easy designing and layoutting. For more professional design and layout, Capture CIS schematic and Allegro are better. BTW, I think there is no point to compare these two different style things.

The auto router is ok for just layoutting a simple circuit. The STM32F313 is a very strange mcu since now STMICRO is not offering any information relate to this mcu.

The circuit is just based on PX4 2.43 circuit. What I was doing is just to edit and delete some thing. I did delete the battery management circuit since I think that is really too much for a middle level flight controller. And I also deleted the LED management circuits. I found that was not really necessary to use.

Also, if thinking about the price of MS5611 IC and MPU6050 , and the potential of damaging them when soldering. It is good to just buy a cheap and small board GY-86 from ebay, which will really save your time.

It is not easy to do the layout when you want to do smaller layout such as 1.5x1.5 inches (Especially when you do the 2-layer). I did not care about the layout at the first time, then it resulted a big layout 3.1x2.15 inches layout and it will take me 35$ in OSHPark..

Anyway, I think I probably will transfer this to allegro. I do think some vertical angles generated by the autorouter is hardly adjusted by hands in eagle.

Here's the layout generated by auto router from EAGLE PCB.




Saturday, February 15, 2014

STM32F103 assembly code for just turning on LED (Keil MDK)

If you ask how pain it is for just using assembly language to turning on the led, I WOULD say very very very very....pain in the ass!!

Last year I was using STK200 which has atmega16 on it. I was able to display a simple digital clock by just using AVR assembly, which just took me several hours to write the code and display it on the Putty.

But I have to admit, Cortex-M3 is so different than that one. It would take several hours to review the ARM instructions and architecture. And probably it will still has compile error in the code.

Here's a little example:


GPIOC_CRL   EQU     0x40011000
GPIOC_CRH   EQU     0x40011004
GPIOC_IDR   EQU     0x40011008
GPIOC_ODR   EQU     0x4001100C
GPIOC_BSRR  EQU     0x40011010
GPIOC_BRR   EQU     0x40011014
GPIOC_LCKR  EQU     0x40011018
;STACK_TOP EQU 0X20002000
    AREA RESET,CODE,READONLY
;DCD STACK_TOP ;MSP pointer
DCD start  ;reset

            AREA    RESET, CODE, READONLY

            ENTRY
start
           
    LDR   r1, =GPIOC_CRH      ; Address for port c control register
            LDR   r0, [r1]
STR   r0, [r1]            ; Write to contorl register

            MOV32   r1, #GPIOC_ODR      ; Address for port c output data register
            MOV     r0, #0x0A00         ; Value for port c
            STR     r0, [r1]            ; Write value
loop
            B       loop
            ALIGN
            END

I ediited a little bit from the original version. You will know that it won't even debug step in for you since the crazy "MOVS R0,R0"....

You will never know how to deal with it unless you know this device, cortex-m3 will probably need to initialize the stack otherwise the debugger will not give a fxxx to you.
So if uncomment the two statements above in the code, the debugging will start working. I would said do not try using pure assembly in CORTEX-M4, that is a different device and more bugs waiting.