2015年11月14日星期六

无线收发器(rf transceiver)


摘自该书的第一张第二节:
  The art of designing modern wireless transceivers has seen extensive progress during the last two decades. The design of these transceivers generally must follow three main factors. They should be high performance, low cost, and able to handle the complex objectives of advanced wireless communication systems. A general block diagram of a wireless transceiver using multiple antennas in both the transmitter and the receiver is shown in Figure 1.4.
  In recent transceivers, a great amount of signal processing is achieved in the baseband using digital signal processors (DSPs), application specific integrated circuits (ASICs), and field-programmable gate arrays (FPGAs). A signal at the output of the baseband section is up-converted to RF frequency using a heterodyne technique or a direct conversion method. A frequency synthesizer provides the carrier signal for up-conversion. The power amplifiers play a crucial role in providing the performance of the system. The RF front-end delivers the signal to the transmitter antennas. After passing through a wireless channel on the receiver side, the signals of the multiple antennas must be down-converted. This process includes RF signal processing using low noise amplifiers (LNAs), frequency synthesizing, and down conversion. Signals must then be delivered to the receiver baseband.
  The excessive signal processing is performed in the receiver to detect the signals. Likewise, on the transmitter side, digital signal processing is carried by receiver digital circuits. 

2015年10月4日星期日

无线MCU

各芯片厂商的无线MCU对比:
1. freescale
飞思卡尔的实现方法是内部集成一个射频模块在内部提供spi接口(接口不外露在线片外)给主内核,也就是说,主核与无线模块的连接是:内部总线-GPIO-无线模块的SPI接口



2.TI
德州仪器的实现方法是内部集成一个射频模块,该模块设置一个cortex-m0处理器来处理通信的操作;而主核与无线部分的通信直接通过总线




爱特梅尔的实现方法是把射频模块和MCU一起集成到同一芯片里,射频模块和MCU的通信方式是通过在芯片内部以SPI接口方式连接,就像上面飞思卡尔的那样。


2015年5月25日星期一

实用工具

本文章格式如下:
@工具名
标签(tag)
源网址( Source URL )

@wavedrom
#波形图 #时序图
介绍地址 工具地址

2014年12月29日星期一

Simplest bare metal program for ARM

原文:https://balau82.wordpress.com/2010/02/14/simplest-bare-metal-program-for-arm/

由于keil-mdk自带的编译器要钱的,所以转向使用免费的GNU的相关工具!

Simplest bare metal program for ARM

Posted on 2010/02/14

Bare metal programs run without an operating system beneath; coding on bare metal is useful to deeply understand how a hardware architecture works and what happens in the lowest levels of an operating system. I wanted to create a simple example of bare metal program for ARM using free open source tools: RealView Development Suite is the state of the art of ARM compilers, but it is expensive for hobbyists; Codesourcery is a company that provides a free version of the GNU gcc toolchain for ARM cores. In particular, the EABI toolchain must be downloaded from their download page; I fetched the IA32 GNU/Linux installer. During the graphical installation, the tools are installed in a sub-folder of the user’s home; this is fine if only a single person wants to use the toolchain on that computer, otherwise it is more efficient to install it system-wide. The path to the toolchain binaries must be added to the PATH environmental variable; usually the installation process does it for you, but if it doesn’t, the standard installation path is “~/CodeSourcery/Sourcery_G++_Lite/bin“.
I created a C file called test.c containing the simplest C code I wanted to compile:
int c_entry() {
  return 0;
}
The classic printf(“Hello world!\n”); example is more complex because when coding bare metal the standard input/output must be defined: it could be a physical serial port for example. I called it c_entry instead of main because in this example some things that are usually assumed true when the program reaches the main code are not implemented: for example, variable initialized globally in C code could not be really initialized.
To compile this code into an object file (test.o) run the following command, very similar to compiling code with gcc:
$ arm-none-eabi-gcc -c -mcpu=arm926ej-s -g test.c -o test.o
The -mcpu flag indicates the processor for which the code is compiled. I wanted to target the ARM926EJ-S processor in this example for these reasons:
  • It’s a widespread core in common products
  • I worked on a project that used this core
  • The QEMU emulator supports this core in the form of a VersatilePB
In order to create a bare metal program we must understand what does the processor do when it is switched on. The ARM9 architecture begins to execute code at a determined address, that could be 0(usually allocated to RAM) or 0xFFFF0000 (usually allocated to Read Only Memory). We must put some special code at that particular address: the interrupt vector table. It is a series of 32-bit instructions that are executed when something special happens: for example when the ARM core is reset, or when the memory contains an unknown instruction that doesn’t belong to the ARM instruction set, or when a peripheral generates an interrupt (the serial port received a byte). The instructions in the interrupt vector table usually make the processor jump to the code that handles the event. The jump can be done with a branch instruction (B in ARM assembly) when the destination address is near.
I created an assembly file called startup.s containing the following code:
.section INTERRUPT_VECTOR, "x"
.global _Reset
_Reset:
  B Reset_Handler /* Reset */
  B . /* Undefined */
  B . /* SWI */
  B . /* Prefetch Abort */
  B . /* Data Abort */
  B . /* reserved */
  B . /* IRQ */
  B . /* FIQ */

Reset_Handler:
  LDR sp, =stack_top
  BL c_entry
  B .
A brief explanation:
  • Line 1 generates a section named INTERRUPT_VECTOR containing executable (“x”) code.
  • Line 2 exports the name _Reset to the linker in order to set the program entry point.
  • Line 3 to 11 is the interrupt vector table that contains a series of branches. The notation “B .” means that the code branches on itself and stays there forever like an endless for(;;);
  • Line 14 initializes the stack pointer, that is necessary when calling C functions. The top of the stack (stack_top) will be defined during linking.
  • Line 15 calls the c_entry function, and saves the return address in the link register (lr).
To compile this code into an object file (startup.o) run the following command:
$ arm-none-eabi-as -mcpu=arm926ej-s -g startup.s -o startup.o
Now we have test.o and startup.o, that must be linked together to become a program. The linking process also defines the address where the program is going to be executed and declares the placement of its sections. To give this information to the linker, a linker script is used. I wrote this linker script, called test.ld, following a simple example in the linker manual:
ENTRY(_Reset)
SECTIONS
{
 . = 0x0;
 .text : {
 startup.o (INTERRUPT_VECTOR)
 *(.text)
 }
 .data : { *(.data) }
 .bss : { *(.bss COMMON) }
 . = ALIGN(8);
 . = . + 0x1000; /* 4kB of stack memory */
 stack_top = .;
}
The script tells the linker to place the INTERRUPT_VECTOR section at address 0, and then subsequently place the code (.text), initialized data (.data) and zero-initialized and uninitialized data (.bss). Line 11 and 12 tells the linker to move 4kByte from the end of the useful sections and then place the stack_top symbol there. Since the stack grows downwards the stack pointer should not exceed its own zone, otherwise it will corrupt lower sections. The script on line 1 tells the linker also that the entry point is at _Reset. To link the program, execute the following command:
$ arm-none-eabi-ld -T test.ld test.o startup.o -o test.elf
This will generate an ELF binary for ARM that can be executed with a simulator, or it can be loaded inside a real ARM core on a hardware board; for simplicity we can use the Codesourcery version of the gdb debugger:
$ arm-none-eabi-gdb test.elf
[...]
This GDB was configured as "--host=i686-pc-linux-gnu --target=arm-none-eabi".
[...]
(gdb) target sim
Connected to the simulator.
(gdb) load
Loading section .text, size 0x50 vma 0x0
Start address 0x0
Transfer rate: 640 bits in <1 sec.
(gdb) break c_entry
Breakpoint 1 at 0x3c: file test.c, line 24.
(gdb) run
Starting program: /home/francesco/src/arm-none-eabi/startup/test.elf 

Breakpoint 1, c_entry () at test.c:24
24        return 0;
(gdb) set $pc=0
(gdb) stepi
Reset_Handler () at startup.s:34
34        LDR sp, =stack_top
  • The target sim command tells the debugger to use its internal ARM simulator,
  • the load command fills the simulator memory with the binary code,
  • the debugger places a breakpoint at the beginning of the c_entry function,
  • the program is executed and stops at the breakpoint,
  • the program counter (pc register) of the ARM core is set to 0 to emulate a software reset,
  • the execution flow can be examined step-by-step in the debugger.
An easier way to debug is using the ddd graphical front-end with the following command:
$ ddd --debugger arm-none-eabi-gdb test.elf
This program is a starting point to begin to develop more elaborate solutions. The next step I want to take is using QEMU as the development target: with it I can interact with some peripherals, even if emulated, and create bare metal embedded programs more useful in the “real world” using only free open source software.
For a deeper look into bare metal programming for ARM see also:

2014年10月13日星期一

(转载)Diy ST link

网址: http://www.micromouseonline.com/2014/01/05/mini-st-linkv2-programmer/
http://www.taylorkillian.com/2013/01/retrieving-st-linkv2-firmware-from.html
http://forum.eepw.com.cn/thread/226668/1
http://forum.easyelectronics.ru/viewtopic.php?f=17&t=6620&start=50

2014年10月8日星期三

SD的SPI模式

参考规格:Physical Layer Simplified Specification 4.10

4.5 Cyclic Redundancy Code (CRC)     生成多项式: G(x) = x7 + x3 + 1 .即0x89

7.3.1.1 Command Format
     命令格式

2014年9月22日星期一

疑问:点解国内流行用ST的ARM内核MCU而不用Atmel

建议初学者要学或者要用某款MCU时,看看其手册写的如何
相关讨论链接:
进军ARM调查:选用那个品牌,那个型 ...
NXP 与 ST 的Cortex-M3的MCU的一点体会!请勿拍砖啊!
STM32用户(数据)手册特别牛,学习经验分享。
从上面连接可以看出原因是ST做的推广比较好(个人感觉ST手册写得太烂)!
还有一些额外知识可从上面获得,那就是要想MCU跑一些大型的系统(eg:linux等)的话那就要要求MCU带外部总线。
我个人认同以下观点:
作者: Swordman    时间: 2011-7-17 15:04
Atmel的SAM3S系列怎么没什么人用呢? 
是不是大家都不关注低功耗的.?
ST的datasheet看的想吐血. 写的很罗嗦又不清楚.. 看惯了Atmel的
作者: huxiaoping    时间: 2011-12-7 14:08
呵呵,ST的最大优势就是便宜,但伴随的问题也最多,那个破函数库写的太烂了,根本就是不深入一定不知道他要干什么?
和大家一样,看ATMEL的数据手册惯了,再看ST的太难受了,很多地方的准确性太差,就好象在看第三方在讲一样,
这里有感触,为啥ATMEL和NXP的新内核上市都很慢啊,而ST那么快,就好比搞精品研发和山寨研发一样,山寨的可以先占领市场和价格做的很低,有问题慢慢改,或者说就那么点钱的玩意,你好意思说啊,呵呵
搞过一个LPC1343的项目,大概看了下手册,连同例子代码,很快东西就出来了,
但是ST的东东随便一个都要去查来查去,代码调的累啊,看完手册还要看函数库的东东,实际上很不想看到多层封装的函数库,硬件问题带来的IIC,USART,RTC更是要注意了,诶,谁让这便宜呢,凑合用吧,





STM32用户(数据)手册特别牛,学习经验分享。的内容摘要:↓
发表于 2009-9-16 08:32:38 | 只看该作者
上次提出过这个问题

st的技术支持说了:俺们的手册是给有经验的工程师看的,显然不是给初学者比如大学生看的:)

建议st借鉴一下atmel的手册,清清楚楚地。nxp的手册也不错

手册清楚了,技术支持的工作量也会比较小