Pulserain Fp51-1T Microcontroller: Technical Reference Manual
Pulserain Fp51-1T Microcontroller: Technical Reference Manual
Sep, 2017
1 INTRODUCTION ............................................................................................................................... 3
2 HARDWARE ..................................................................................................................................... 5
3 SOFTWARE .................................................................................................................................... 30
References
1. MCS-51 Programmer's Guide and Instruction Set, Intel Corporation.
2. Building Embedded Systems – Programmable Hardware, Changyi Gu, APress Media, July 2016
http://www.apress.com/us/book/9781484219188
3. SDCC Compiler User Guide, SDCC 3.6.0, 2016-06-04, Rev 9615 (http://sdcc.sourceforge.net)
4. Computer Organization and Design - The Hardware / Software Interface (3rd edition), David A.
Patterson and John L. Hennessy, Morgan Kaufmann Publication, 2005
5. Wishbone B4, WISHBONE System-on-Chip (SoC) Interconnection Architecture for Portable IP Cores,
OpenCores Organization, 2010
6. PulseRain M10 – I2C, Technical Reference Manual, Doc# TRM-0922-01007, Rev 1.0.0, 09/2017
https://github.com/PulseRain/M10I2C/raw/master/extras/M10_I2C_TRM.pdf
7. PulseRain M10 – PWM, Technical Reference Manual, Doc# TRM-0922-01009, Rev 1.0.1, 10/2017,
https://github.com/PulseRain/M10PWM/raw/master/extras/M10_PWM_TRM.pdf
8. PulseRain M10 – microSD, Technical Reference Manual, Doc# TRM-0922-01006, Rev 1.0.0, 09/2017
https://github.com/PulseRain/M10SD/raw/master/extra/M10_SD_TRM.pdf
9. PulseRain M10 – Voice CODEC, Technical Reference Manual, Doc# TRM-0922-01001, Rev 1.0.3,
09/2017, https://github.com/PulseRain/M10CODEC/raw/master/extras/M10_CODEC_TRM.pdf
10. PulseRain M10 – ADC, Technical Reference Manual, Doc# TRM-0922-01003, Rev 1.0.0, 09/2017
https://github.com/PulseRain/M10ADC/raw/master/extra/M10_ADC_TRM.pdf
11. PulseRain M10 – JTAG, Technical Reference Manual, Doc# TRM-0922-01008, Rev 1.0.0, 09/2017
https://github.com/PulseRain/M10JTAG/raw/master/extras/M10_JTAG_TRM.pdf
12. PulseRain M10 – SRAM, Technical Reference Manual, Doc# TRM-0922-01004, Rev 1.0.0, 09/2017
https://github.com/PulseRain/M10SRAM/raw/master/extras/M10_SRAM_TRM.pdf
13. PulseRain M10 – DTMF, Technical Reference Manual, Doc# TRM-0922-01002, Rev 1.0.0, 09/2017
https://github.com/PulseRain/M10DTMF/raw/master/extras/M10_DTMF_TRM.pdf
14. PulseRain M10 – Serial Port, Technical Reference Manual, Doc# TRM-0922-01005, Rev 1.0.0,
09/2017, https://github.com/PulseRain/M10SerialAUX/raw/master/extras/M10_Serial_TRM.pdf
15. PulseRain M10 – Quick Start Guide, Doc#QSG-0922-0039, Rev 1.2.0, 10/2017
https://github.com/PulseRain/Arduino_M10_IDE/blob/master/docs/M10_quick_start.pdf
16. C++ preprocessor __VAR_ARGS__ number of arguments,
https://stackoverflow.com/questions/2124339/c-preprocessor-va-args-number-of-arguments
17. C Pre-Processor Magic, by Jonathan Heathcote, http://jhnet.co.uk/articles/cpp_magic
18. MicroChip 23A1024/23LC1024 1Mbit SPI Serial SRAM with SDI and SQI Interface Datasheet,
DS20005142C
19. Si3000 Voice Band CODEC with Microphone / Speaker Drive, Rev 1.4, Silicon Laboratories, 12/2010
1|Page
PulseRain FP51-1T MCU – Technical Reference Manual
2|Page
PulseRain FP51-1T MCU – Technical Reference Manual
1 Introduction
Instruction Interrupt
Fetch Controller
Onchip
User Flash Memory
Host PC
Putting MCU core into FPGA is becoming a universal practice these days. However, most MCU soft cores
available today are tied to specific FPGA vendors, with close source implementation. And there will be oodles
of hoops for engineers to jump through if they decide to migrate from one proprietary core to another. To
break the status quo, PulseRain Technology has come up with the open source FP51-1T core (Named after
the legendary P-51 Mustang Fighter-bomber.) for a more portable FPGA solution.
As shown in Figure 1-1, the FP51-1T is a high performance 8-bit MCU core, compatible with Intel 8051 ISA.
With a crafty RISC implementation, this core can achieve single clock cycle execution for most instructions,
while pushing the clock rate above 96MHz. (Silicon Proven on the low speed -8 grade device in Intel/Altera
MAX 10 family).
To facilitate debugging, an OCD (On Chip Debugger) is also provided along with the MCU core. The OCD can
communicate with host PC through RS232 protocol. And it supports features like code downloading, single
step execution, hardware breakpoint etc. A software package for Arduino IDE is also provided to support the
Arduino Language.
And with great flexibility, new peripherals can be added and customized through Wishbone bus interface.
The revision A0 of FP51-1T MCU supports the following peripherals:
• Timer
3|Page
PulseRain FP51-1T MCU – Technical Reference Manual
• UART
• I2C
• PWM
• ADC
• microSD
• Serial SRAM (Microchip 23LC1024)
• Voice CODEC (Silicon Lab Si3000)
• JTAG UART
To facilitate the software development, PulseRain Technology has also provided Arduino libraries for those
peripherals. Some application specific libraries are also offered, like the following:
And all the code can be found on PulseRain Technology's public repositories: http://git.pulserain.com
4|Page
PulseRain FP51-1T MCU – Technical Reference Manual
2 Hardware
2.1 Processor Core
2.1.1 Hardware Architecture
Instruction Fetch
Onchip
Code Memory
Instruction
Decode Set 1
Onchip
Data Memory
Read Address
Memory Read
IDATA
OCD
General Purpose
Register
Forward
XDATA
Write Data
Execution
As shown in Figure 2-1, the FP51-1T processor core has a Harvard memory architecture with 5 pipeline stages.
In other words, the memory is divided into two separate address spaces: The memory space for code and
the one for data. The code memory is addressed by a 16-bit PC (Program Counter), so the maximum code
memory space is 64KB. The data memory space is divided into two sub spaces: IDATA and XDATA. The IDATA
space is addressed by an 8-bit address, which has the maximum space size of 256 bytes. The XDATA is
addressed by a 16-bit address, which theoretically has a maximum space size of 64KB. On FP51-1T, the IDATA
and XDATA are physically merged into one block memory, so the actual available XDATA space on FP51-1T is
64KB - 256 Byte.
5|Page
PulseRain FP51-1T MCU – Technical Reference Manual
2.1.1.1 Registers
Within the IDATA address space, some of the addresses are used by memory mapped registers. These
registers are as following:
Bit Address
Address Register Description
(MSB ~ LSB)
0x81 SPL The lower 8 bits of stack pointer N/A
The lower 8 bits of data pointer
0x82 DPL N/A
(DPTR)
The higher 8 bits of data pointer
0x83 DPH N/A
(DPTR)
0x87 PCON Power Control (N/A on FP51-1T) N/A
0xD0 PSW Program Status Word 0xD7 ~ 0xD0
0xE0 ACC Accumulator 0xE7 ~ 0xE0
0xE6 MCU_REVISION Revision of the MCU (Read Only). N/A
0xE7 XPAGE Page Index for XDATA memory access N/A
0xEF SPH The higher 8 bits of stack pointer N/A
B Register. Used by MUL / DIV
0xF0 B 0xF7 ~ 0xF0
instructions
Table 2-2 Address Mapping for SFR (Processor Core Related)
➢ Stack Pointer
The FP51-1T supports 16-bit stack pointer, for which the lower 8 bits are stored in SPL while
the higher 8-bits are in SPH.
6|Page
PulseRain FP51-1T MCU – Technical Reference Manual
➢ DPTR (Data Pointer)
The XDATA can be accessed with a 16-bit data pointer (DPTR). The lower 8 bits of DPTR are
stored in DPL while the higher 8 bits are in DPH.
➢ MCU_REVISION
Currently only Revision A0 is supported.
➢ XPAGE
As mentioned early, the XDATA can be accessed with a 16-bit address. One way to form this
16-bit address is to use the DPTR. The other way is to use a page window, for which the
higher 8 bits of the address (page index) is stored in the XPAGE register, and the lower 8 bits
are stored in a general-purpose register (R0 – R7). In this way, the XDATA can be addressed
by MOVX instruction with a page size of 256 bytes.
Note: As mentioned early, the SFR occupies the address from 0x80 to 0xFF. In the classic 8051, the internal
RAM that overlaps with SFR can still be accessed through indirect addressing mode, such as "ADD A, @R0".
In this way, there could be a saving of 128 bytes of memory. But for modern day FPGAs, block RAM is no
longer a scarce resource. The FP51-1T thus chooses NOT to support such address overlay in favor of concise
design and higher clock rate. In other words, when it comes to the address from 0x80 to 0xFF, all the
addressing mode will get funneled to the SFR. In the eyes of classic 8051, the FP51-1T can equivalently be
viewed as if it only carries 128 bytes of internal RAM and a large sum of external RAM.
2.1.1.2 Pipeline
Notwithstanding the fact that 8051 has a CISC ISA, it is still possible to translate those instructions into
microoperations and apply a RISC implementation on top of it (Ref [2]). And this is exactly the approach that
FP51-1T is taken. The first 8051 came out with 12 clock cycles per instruction (called 12T). With a RISC
implementation like FP51-1T, the instruction can be executed at a maximum throughput of 1 clock cycle per
instruction. (That's why it has a "1T" in its name.)
7|Page
PulseRain FP51-1T MCU – Technical Reference Manual
As illustrated in Figure 2-1, the FP51-1T is implemented with a 5-stage pipeline. The 5 stages are:
• Instruction Fetch
• Instruction Decode for Set 1
• Memory Read
• Instruction Decode for Set 2
• Execution
The instructions are divided into two sets, set 1 and set 2. Those instructions in set 2 don't have to access the
memory and are less complicated than those in set 2. And they are decoded separately to balance the work
load so that higher clock rate can be achieved. The data memory, including those registers, are implemented
as a simple dual port memory (one read-port, one write-port). In this way, the Memory Read Stage and the
Execute State can work simultaneously to avoid structural hazards in pipeline (Ref [4]).
• Data Forwarding
If the write address of the first instruction is the read address of the second instruction, the result of
the first instruction will be forwarded to the second instruction through a bypass path, as illustrated
in Figure 2-1. In this way, the pipeline can be kept running without stalling. An example of such case
is the following:
INC R1
ADD A, R1
In the above example, the R1 will be updated with data forwarding without any pipeline stall.
8|Page
PulseRain FP51-1T MCU – Technical Reference Manual
world-wide. (As of today, there are more than 70 of them.). Part of its popularity comes from the fact that it
is not burdened by license/royalty/patent, as it has fallen into public domain thanks to its longevity and
vitality. That's why it is picked for FP51-1T as a good option of open source implementation.
9|Page
PulseRain FP51-1T MCU – Technical Reference Manual
2.1.2.2 Bit Addressable Location
Some of the memory locations in IDATA can be manipulated bit-wise by those instructions listed in Table 2-7.
These memory locations are:
• Arithmetic Instructions
• Logical Instructions
• Data Transfer Instructions
• Instructions for Bit Operations
• Branching Instructions
And those instructions are detailed below in Table 2-4, Table 2-5, Table 2-6, Table 2-7 and Table 2-8.
Fortunately, users don't have to program directly in the assembly language. With the Arduino compatible
library provided by PulseRain Technology, users can program with more user-friendly Arduino language, as
later sections will demonstrate.
10 | P a g e
PulseRain FP51-1T MCU – Technical Reference Manual
11 | P a g e
PulseRain FP51-1T MCU – Technical Reference Manual
12 | P a g e
PulseRain FP51-1T MCU – Technical Reference Manual
If (CY == 1) then
(PC) <= (PC) + rel + 2
JC rel 0x40 2 2/9 else
(PC) <= (PC) + 2
end if
If (CY == 0) then
(PC) <= (PC) + rel + 2
JNC rel 0x50 2 2/9 else
(PC) <= (PC) + 2
end if
If ((bit) == 1) then
(PC) <= (PC) + rel + 2
JB bit, rel 0x20 3 2/9 else
(PC) <= (PC) + 2
end if
If ((bit) == 0) then
(PC) <= (PC) + rel + 2
JNB bit, rel 0x30 3 2/9 else
(PC) <= (PC) + 2
end if
If ((bit) == 1) then
(PC) <= (PC) + rel + 3
(bit) <= 0
JBC bit, rel 0x10 3 2/9
else
(PC) <= (PC) + 3
end if
Table 2-7 Instructions of Bit Operation
13 | P a g e
PulseRain FP51-1T MCU – Technical Reference Manual
AJMP addr11 8'b???0_0001 2 9 Absolute Jump (See Ref [1] for more detail.)
LJMP addr16 0x02 3 9 Long Jump (See Ref [1] for more detail.)
SJMP rel 0x80 2 1 Short Jump (See Ref [1] for more detail.)
JMP @A + DPTR 0x73 1 9 Indirect Jump (See Ref [1] for more detail.)
DJNZ direct, rel 0xD5 3 2/9 Decrement direct data, and jump if not zero
DJNZ Ri, Rel (i = 0 ~ 7) 0xD8 ~ 0xDF 2 2/9 Decrement register, and jump if not zero
14 | P a g e
PulseRain FP51-1T MCU – Technical Reference Manual
2.2 Peripherals
2.2.1 Wishbone FASM Interface
As illustrated in Figure 1-1, all the peripheral registers for FT51-1T are mapped into the SFR address space,
and are accessed through Wishbone FASM interface (Ref [5]). All peripherals share the same Wishbone bus,
and the processor core is the only master on the bus.
For master read, the signals are as following on the master side:
CLK
RD_STB_O
RD_ACK_I
15 | P a g e
PulseRain FP51-1T MCU – Technical Reference Manual
For master write, the signals are as following on the master side:
CLK
WR_STB_O
WR_WE_O
Write Data
RD_DAT_I Valid
16 | P a g e
PulseRain FP51-1T MCU – Technical Reference Manual
2.2.2 SFR (Special Function Register)
Bit Address
Address Register Name Description
(MSB ~ LSB)
0x80 P0 IO Port 0 0x87 ~ 0x80
0x88 TCON Timer Control 0x8F ~ 0x88
0x89 TMOD Timer Mode N/A
0x8A TL0 Timer 0 lower byte N/A
0x8B TL1 Timer 1 lower byte N/A
0x8C TH0 Timer 1 higher byte N/A
0x8D TH1 Timer 1 higher byte N/A
0x90 P1 IO Port 1 0x97 ~ 0x90
0x98 SCON UART Control (Serial Port Control) 0x9F ~ 0x98
0x99 SBUF In / Out buffer for the UART (Serial Port) N/A
0x9A SCON_AUX Control for the auxiliary UART N/A
0x9B SBUF_AUX In / Out buffer for the auxiliary UART N/A
0xA0 P2 IO Port 2 0xA7 ~ 0xA0
Interrupt Enable (See Table 2-13 for
0xA8 IE 0xAF ~ 0xA8
more detail.)
0xB0 P3 IO Port 3 0xB7 ~ 0xB0
Interrupt Priority (See Table 2-14 for
0xB8 IP 0xBF ~ 0xB8
more detail.)
0xC0 DEBUG-COUNTER-LED See Section 2.2.14. N/A
0xD1 I2C_CSR Registers for I2C. See Ref [6] for more N/A
0xD2 I2C_ADDR-DATA detail. N/A
0xD3 PWM_CSR Registers for PWM. See Ref [7] for more N/A
0xD4 PWM_DATA detail. N/A
0xD7 SD_CSR N/A
0xD8 SD_CMD N/A
0xD9 SD_ARG0 N/A
0xDA SD_ARG1 N/A
Register for microSD, See Ref [8] for
0xDB SD_ARG2 N/A
more detail.
0xDC SD_ARG3 N/A
0xDD SD_BUF N/A
0xDE SD_DATA_IN N/A
0xDF SD_DATA_OUT N/A
0xE8 CODEC_WRITE_DATA_LOW N/A
0xE9 CODEC_WRITE_DATA_HIGH N/A
Register for voice CODEC (Silicon Lab
0xEA CODEC_READ_DATA_LOW N/A
Si3000). See Ref [9] for more detail.
0xEB CODEC_READ_DATA_HIGH N/A
0xEC CODEC_CSR N/A
0xED CHIP_ID_DATA_CSR Chip ID for Intel MAX 10 FPGA. N/A
0xF1 P0_DIRECTION IO direction for Port 0 N/A
17 | P a g e
PulseRain FP51-1T MCU – Technical Reference Manual
Bit Address
Address Register Name Description
(MSB ~ LSB)
0xF2 P1_DIRECTION IO direction for Port 1 N/A
0xF3 P2_DIRECTION IO direction for Port 2 N/A
0xF4 P3_DIRECTION IO direction for Port 3 N/A
0xF5 ADC_DATA_HIGH N/A
Register for the on-chip ADC in Intel MAX
0xF6 ADC_DATA_LOW N/A
10 FPGA. See Ref [10] for more detail.
0xF7 ADC_CSR N/A
Register for JTAG UART. See Ref [11] for
0xF8 JTAG_UART N/A
more detail.
0xF9 SRAM_INSTRUCTION N/A
0xFA SRAM_DATA N/A
0xFB SRAM_ADDRESS2 N/A
Register for SPI SRAM (Microchip
0xFC SRAM_ADDRESS1 N/A
23LC1024). See Ref [12] for more detail.
0xFD SRAM_ADDRESS0 N/A
0xFE SRAM_CSR N/A
Table 2-11 Peripheral Address Mapping
ISR Address
Interrupt Source Description
(in Code Memory)
0x0000 Power-on Reset Put a long jump here to jump to the start of user program
0x0003 External INT0 The INT0 pin of the MCU, level signal expected
0x000B Timer0 Pulse Signal
0x0013 I2C Slave Interrupt for I2C Slave controller, level signal expected
0x001B Timer1 Pulse Signal
0x0023 UART Level Signal
0x002B ADC Level Signal
0x0033 CODEC (Si3000) Pulse Signal
Table 2-12 Interrupt Vector Table
18 | P a g e
PulseRain FP51-1T MCU – Technical Reference Manual
2.2.3.2 Interrupt Enable / Disable
The 7 interrupt sources can be enabled/disabled both individually and globally by a SFR called IE (Interrupt
Enable). The bit map of the IE register is detailed below in Table 2-13.
Byte
Bits Index Bit Address Default Description
Address
0 0xA8 0 Enable bit for External INT0
1 0xA9 0 Enable bit for Timer0 Interrupt
2 0xAA 0 Enable bit for I2C slave interrupt
3 0xAB 0 Enable bit for Timer1 Interrupt
0xA8
4 0xAC 0 Enable bit for UART Interrupt
5 0xAD 0 Enable bit for interrupt from on-chip ADC
6 0xAE 0 Enable bit for CODEC (Si3000) Interrupt
7 0xAF 0 Global Interrupt Enable bit
Table 2-13 Bit Map for SFR: IE (Interrupt Enable)
Byte
Bits Index Bit Address Default Description
Address
0 0xB8 0 Priority bit for External INT0
1 0xB9 0 Priority bit for Timer0 Interrupt
2 0xBA 0 Priority bit for I2C slave interrupt
3 0xBB 0 Priority bit for Timer1 Interrupt
0xB8
4 0xBC 0 Priority bit for UART Interrupt
5 N/A 0 Priority bit for interrupt from on-chip ADC
6 N/A 0 Priority bit for CODEC (Si3000) Interrupt
7 N/A 0 Reserved
Table 2-14 Bit Map for SFR: IP (Interrupt Priority)
Interrupts with low priority can be overridden by those with high priority. When two interrupts with the same
priority hit simultaneously, they will be served in a round robin fashion.
19 | P a g e
PulseRain FP51-1T MCU – Technical Reference Manual
2.2.4 IO Port
The FP51-1T MCU has 4 IO ports, and each port is 8-bit wide. They are all bit-addressable, as shown in Table
2-11.
These ports are bi-directional, and the direction for each IO pin is controlled by the SFR Px_DIRECTION, where
x = 0 ~ 3. A bit 1 in Px_DIRECTION will set the correspondent IO pin of Port x as output, while a bit 0 will set
the IO pin as input.
2.2.5 Chip ID
For Intel/Altera MAX 10 FPGA, each device has a 64-bit chip ID that can uniquely identify the device, and this
64-bit number can be obtained by using the "Altera_unique_chip_ID" IP core. For FP51-1T Rev A0 MCU, a
Wishbone wrapper has been provided to integrate this IP core into the peripheral bus, with the following
register mapping:
To obtain the 64-bit Chip ID, the following operations need to be carried out:
2.2.6 I2C
I2C protocol, both master and slave mode, is supported by FP51-1T Rev A0. The details of the PulseRain I2C
controller and the correspondent software library can be found in
Ref [6]: PulseRain M10 – I2C, Technical Reference Manual, Doc# TRM-0922-01007, Rev 1.0.0, 09/2017
https://github.com/PulseRain/M10I2C/raw/master/extras/M10_I2C_TRM.pdf
2.2.7 PWM
By default, the FP51-1T Rev A0 has 6 PWM output that can be configured individually. The details of the
PulseRain PWM controller and the correspondent software library can be found in
Ref [7]: PulseRain M10 – PWM, Technical Reference Manual, Doc# TRM-0922-01009, Rev 1.0.1, 10/2017,
https://github.com/PulseRain/M10PWM/raw/master/extras/M10_PWM_TRM.pdf
20 | P a g e
PulseRain FP51-1T MCU – Technical Reference Manual
2.2.8 microSD
The SPI mode of Secure Digital Card is supported by FP51-1T Rev A0, for which a hardware microSD controller
is offered by PulseRain Technology. This microSD controller has 1KB (2 disk sectors) of data buffer for
ping/pong operation. On top of that, the correspondent software library also supports read/write at file
system level. For more information, please refer to
Ref [8]: PulseRain M10 – microSD, Technical Reference Manual, Doc# TRM-0922-01006, Rev 1.0.0, 09/2017
https://github.com/PulseRain/M10SD/raw/master/extra/M10_SD_TRM.pdf
Ref [9], PulseRain M10 – Voice CODEC, Technical Reference Manual, Doc# TRM-0922-01001, Rev 1.0.3,
09/2017, https://github.com/PulseRain/M10CODEC/raw/master/extras/M10_CODEC_TRM.pdf
In addition, a DTMF decoder library has been offered based on the CODEC hardware and software. And its
correspondent details can be found in
Ref [13], PulseRain M10 – DTMF, Technical Reference Manual, Doc# TRM-0922-01002, Rev 1.0.0, 09/2017
https://github.com/PulseRain/M10DTMF/raw/master/extras/M10_DTMF_TRM.pdf
Ref [10]: PulseRain M10 – ADC, Technical Reference Manual, Doc# TRM-0922-01003, Rev 1.0.0, 09/2017
https://github.com/PulseRain/M10ADC/raw/master/extra/M10_ADC_TRM.pdf
Ref [11], PulseRain M10 – JTAG, Technical Reference Manual, Doc# TRM-0922-01008, Rev 1.0.0, 09/2017
https://github.com/PulseRain/M10JTAG/raw/master/extras/M10_JTAG_TRM.pdf
21 | P a g e
PulseRain FP51-1T MCU – Technical Reference Manual
2.2.12 Serial SRAM (Microchip 23LC1024)
The FPT51-1T Rev A0 supports a serial SRAM (128KB) from Microchip, with the part number of 23LC1024.
The details of the SRAM controller and the correspondent software library can be found in
Ref [12]: PulseRain M10 – SRAM, Technical Reference Manual, Doc# TRM-0922-01004, Rev 1.0.0, 09/2017
https://github.com/PulseRain/M10SRAM/raw/master/extras/M10_SRAM_TRM.pdf
2.2.13 UART
The FP51-1T Rev A0 supports two UARTs, both can reach a baud rate up to 921600 bps. The details of the
UART controller and the correspondent software library can be found in
Ref [14]: PulseRain M10 – Serial Port, Technical Reference Manual, Doc# TRM-0922-01005, Rev 1.0.0,
09/2017, https://github.com/PulseRain/M10SerialAUX/raw/master/extras/M10_Serial_TRM.pdf
2.2.14 Debug-Counter-LED
To help debug, the FP51-1T Rev A0 has a register called DEBUG-COUNTER-LED, with the address of 0xC0
(Table 2-11). It is actually a combination of watch dog timer and LED flashing. Internally there are two
counters rolling:
1. The flashing counter, which controls the frequency of the LED flashing. And it is a 27-bit free rolling
counter. So if the LED ever flashes, it will flash at a frequency of 96Mhz / (2**27) = 0.7 Hz.
2. The watch dog counter, which is a 16-bit value. When the DEBUG-COUNTER-LED register is being
written with an 8-bit value Y, the watch dog counter will be loaded with a value of {Y, 8'hFE}. And the
watch dog counter will also keep incrementing until it reaches 16'hFFFF, which will trigger the watch
dog and stop the flashing of LED. To reset the watch dog that has been triggered, simply write zero
the DEBUG-COUNTER-LED register.
Thus, to avoid "being bitten by the dog", it is suggested to write to the DEBUG-COUNTER-LED periodically
with a small value (such as 1). And the LED is supposed to keep flashing under normal circumstance.
22 | P a g e
PulseRain FP51-1T MCU – Technical Reference Manual
MCU
RX
Main
Code RAM UART TX_MCU
TX
RS232 / USB
OCD
TX_OCD Host PC
Debug
UART RX
Debug
Co-Processor
Debug
Reply
The MCU and the OCD can share the same UART port, as illustrated in Figure 2-4. The RX signal goes to both
the MCU and OCD, while the TX signal has to go through a mux. And that mux is controlled by the OCD. After
power-on reset, the MCU has the TX by default. But a valid debug frame sending from the host PC can let
OCD to reconfigure the mux and switch the TX to OCD, for which the code RAM and MCU's internal status
can be accessed and controlled.
Unlike Arduino, the FP51-1T MCU does not use software bootloader to interact with the host PC, because its
hardware OCD can take on chores like code downloading. Thus, the precious code RAM can all be dedicated
to doing the real job.
The debug frame (from host PC to OCD) has the format shown in Table 2-6:
23 | P a g e
PulseRain FP51-1T MCU – Technical Reference Manual
The frame type in Table 2-6 has 8 bits. Among the 8 bits, bit 7 ~ bit 1 are the 7 bits value of frame type. Bit 0
is supposed to toggle between frames, so that a missing frame can be detected.
Please see the correspondent ACK frame in Table 2-21 for more detail.
24 | P a g e
PulseRain FP51-1T MCU – Technical Reference Manual
• 7'h5D: 4-Byte Code RAM write with ACK
Use this frame to write 4 bytes of data into code RAM, with the following format for payload (byte 4 – 9 in Table
2-16).
25 | P a g e
PulseRain FP51-1T MCU – Technical Reference Manual
2.3.3 ACK Frame Format
The ACK frame from OCD to host PC has the similar format as that of debug frame, but the sync word is
different. As mentioned early, each transaction is initiated by the host PC, the ACK is only a response to a
debug frame received early.
The ACK frame (from host PC to OCD) has the format shown in Table 2-20 The Format of ACK Frame:
The frame type in ACK frame will have the same value as its correspondent debug frame. The respective
payload formats are as following:
26 | P a g e
PulseRain FP51-1T MCU – Technical Reference Manual
• 7'h5D: 4-Byte Code RAM write with ACK
• 7'h5B: 128-Byte Code RAM write with ACK
The payload format for those frames are as following:
Group Bit
Signal Name In/Out Description
Name Width
Clock / clk Input 1 Clock input, 96MHz
Reset reset Input 1 Asynchronous reset, active low
inst_mem_we Input 1 write enable for instruction memory (code memory)
inst_mem_wr_addr Input 16 write address for instruction memory
inst_mem_data_in Input 32 write data for instruction memory, little endian
Instruction
inst_mem_re Input 1 read enable for instruction memory
Memory r/w
inst_mem_re_addr Input 16 read address for instruction memory
inst_mem_re_enable_out Output 1 enable out for instruction memory read
inst_mem_data_out Output 32 instruction memory read data, little endian
External
INTx Input 2 INT0 and INT1 for external interrupt
Interrupt
UART_RXD Input 1 RX pin for the main serial port
UART_TXD Output 1 TX pin for the main serial port
UART
UART_AUX_RXD Input 1 RX pin for the auxiliary serial port
UART_AUX_TXD Output 1 TX pin for the auxiliary serial port
IO Port P0 In/Out 8 IO port 0
27 | P a g e
PulseRain FP51-1T MCU – Technical Reference Manual
Group Bit
Signal Name In/Out Description
Name Width
P1 In/Out 8 IO port 1
P2 In/Out 8 IO port 2
P3 In/Out 8 IO port 3
pause Input 1 pause the processor core
break_on Input 1 enable the hardware breakpoint
break_addr_A Input 16 address for hardware breakpoint A
break_addr_B Input 16 address for hardware breakpoint B
run_pulse Input 1 pulse for processor core single step execution
debug_stall Output 1 flag to indicate if the processor core is suspended
Debug
debug_PC Output 16 The current PC value of processor core
timer_pulse_out Output 1 Pulse Out of Timer 0
debug_led Output 1 debug_led out, See Section 2.2.14.
A pulse will be generated when DEBUG_COUNTER_LED
debug_counter_pulse Output 1 register is written with a non-zero value. See Section
2.2.14.
mem_so Input 1 SRAM Serial Out. See Ref [18] for more detail.
mem_si Output 1 SRAM Serial In. See Ref [18] for more detail.
SRAM mem_hold_n Output 1 SRAM Hold, active low. See Ref [18] for more detail.
mem_cs_n Output 1 SRAM chip select, active low. See Ref [18] for more detail.
mem_sck Output 1 SRAM Serial clock. See Ref [18] for more detail
Si3000_SDO Input 1 CODEC Serial Data Out. See Ref [19] for more detail.
Si3000_SDI Output 1 CODEC Serial Data In. See Ref [19] for more detail.
Voice Si3000_SCLK Input 1 CODEC Serial Clock. See Ref [19] for more detail.
CODEC Si3000_MCLK Output 1 CODEC Main Clock. See Ref [19] for more detail.
Si3000_FSYNC_N Input 1 CODEC Frame Sync, active low. See Ref [19] for more detail.
Si3000_RESET_N Output 1 CODEC reset, active low. See Ref [19] for more detail.
sd_cs_n Output 1 SD Card chip select, active low
microSD sd_spi_clk Output 1 SD Card SPI clock
Card sd_data_out Input 1 Serial data from SD card to FPGA
sd_data_in Output 1 Serial data from FPGA to SD card
adc_pll_clock_clk Input 1 2MHz clock from external PLL for the on-chip ADC
ADC
adc_pll_locked_export Input 1 The PLL locked signal from external PLL
sda_in Input 1 I2C SDA input
scl_in Input 1 I2C SCL input
I2C I2C SDA output (sda_in/sda_out should be merged with a
sda_out Output 1
tri-state at FPGA top level. So are scl_in/scl_out)
scl_out Output 1 I2C SCL output
PWM pwm_out Output 6 PWM output
Table 2-24 Port List for FP51-1T MCU
28 | P a g e
PulseRain FP51-1T MCU – Technical Reference Manual
2.5 Repository
The System Verilog code for the FP51-1T MCU can be found on GitHub
https://github.com/PulseRain/PulseRain_FP51_MCU
The correspondent processor core and peripherals can be found in its "submodules" folder.
Ref [15]: PulseRain M10 – Quick Start Guide, Doc#QSG-0922-0039, Rev 1.2.0, 10/2017
https://github.com/PulseRain/Arduino_M10_IDE/blob/master/docs/M10_quick_start.pdf
29 | P a g e
PulseRain FP51-1T MCU – Technical Reference Manual
3 Software
With a dexterous manipulation of C compiler, the FP51-1T MCU can provide a software interface that is
compatible with the Arduino. In other words, through Arduino IDE, users can write sketches in Arduino
Language and program the FP51-1T MCU the same way it works for AVR chips.
3.1 Compiler
Presently there are several commercial vendors that provide C/C++ compilers for 8051 instruction-set, such
as IAR Systems and ARM/Keil. However, to make the FP51-1T MCU 100% open source, decisions have been
made to use the SDCC (Ref [3]) as the default C compiler for FP51-1T.
As mentioned early, the FP51-1T MCU has internal XDATA, and it uses XPAGE register (Section 2.1.1.1) to
access the internal XDATA. The address of the XPAGE register for FP51-1T is 0xE7 (Table 2-2), and the SDCC
compiler needs to be configured with this XPAGE address.
The biggest shortcoming for traditional 8051 architectures is that it has a relatively small stack space (256
bytes), as it is limited by the single byte SP (Stack Pointer). And the FP51-1T has taken several approaches in
both hardware and software to alleviate this constraint:
• The FP51-1T has added another stack pointer register (SPH, in Table 2-2) to extend the stack pointer to
be 16 bits
• The SDCC compiler has been configured to work in large memory model, so that the stack will reside in
the XDATA space
• Most API functions are compiled as non-entrant function calls to save stack space
The second option is more straightforward and does not require complicated scheduler, at the expense of
resource efficiency. For microprocessor, especially for those whose jobs can be handled with less than 64KB
of code, options 2 is often the preferred the choice. And this is also the approach that both Arduino and
FP51-1T take.
30 | P a g e
PulseRain FP51-1T MCU – Technical Reference Manual
With the Arduino IDE, the user will provide a sketch that must contain the following two functions:
• setup()
• loop()
The setup() will be called only once, while the loop() will be invoked repetitively. In fact, behind the scene,
the Arduino will also wrapper those two functions in the way shown in Figure 3-1.
#include "Arduino.h"
void main()
{
setup();
while(1) {
loop();
}
}
Please note that String object is currently not supported by FP51-1T's software library.
31 | P a g e
PulseRain FP51-1T MCU – Technical Reference Manual
3.2.3 APIs
Compatible with Arduino Language, the following APIs are supported by FP51-1T's software library:
3.2.3.1 Digital IO
• void pinMode (uint8_t pin, uint8_t mode)
Parameters:
pin: IO pin index (0 ~ 15). The mapping of pin index to IO port is as the following:
pin index (0 ~ 7) => Port A (0 ~ 7)
pin index (8 ~ 15) => Port B (0 ~ 7)
mode: INPUT or OUTPUT (Behind the scene, INPUT / OUTPUT are defined as the following:
#define INPUT 0
#define OUTPUT 1
Parameters:
pin: IO pin index (0 ~ 15).
value: HIGH or LOW (Behind the scene, HIGH / LOW are defined as the following:
#define HIGH 1
#define LOW 0
Remarks: Use this function to set the logic value of the IO pin
Parameters:
pin: IO pin index (0 ~ 15).
Return Value: The current logic value of the IO pin (LOW (0) or HIGH (1))
Remarks: Use this function to get the current logic value of the IO pin
32 | P a g e
PulseRain FP51-1T MCU – Technical Reference Manual
3.2.3.2 Analog IO
• uint16_t analogRead(uint8_t channel_index)
Parameters:
channel_index: index for analog channel (0 ~ 5)
Return Value: The converted value from the designated analog channel (12-bit unsigned)
Remarks: Use this function to get the current value of the designated A/D channel. For FP51-1T
MCU, this function is part of the M10ADC library, so the user needs to include "M10ADC.h" before
calling this function.
• analogWrite(...)
Arduino uses analogWrite() function for PWM. And in this regard, the FP51-1T has a full-blown PWM
library called M10PWM. For more details of the M10PWM library, please see
Ref [7]: PulseRain M10 – PWM, Technical Reference Manual, Doc# TRM-0922-01009, Rev 1.0.1,
10/2017, https://github.com/PulseRain/M10PWM/raw/master/extras/M10_PWM_TRM.pdf
• analogReference(...)
Arduino uses analogReference() function to specify the reference source for A/D Converter (Internal
/ External). For FP51-1T MCU, only internal reference is used at this point. Thus, this function is not
available on FP51-1T.
3.2.3.3 Time
• void delay (uint32_t delay_in_ms)
Parameters:
delay_in_ms: delay value in millisecond
Parameters:
delay_in_us: delay value in microsecond
33 | P a g e
PulseRain FP51-1T MCU – Technical Reference Manual
• uint32_t millis ()
Parameters: None
Remarks: Use this function to get the number of milliseconds passed since reset
• uint32_t micros ()
Parameters: None
Remarks: Use this function to get the number of microseconds passed since reset
3.2.3.4 Interrupt
• void interrupts()
Parameters: None
• void noInterrupts ()
Parameters: None
34 | P a g e
PulseRain FP51-1T MCU – Technical Reference Manual
3.2.3.5 ISR Handler
• void attachIsrHandler(uint8_t index, void (*isr_handler_pointer)())
Parameters:
index: IRQ index, the valid values for FP51-1T Rev A0 are:
0 => External Interrupt 0,
1 => Timer 0,
2 => I2C Controller,
3 => Timer 1,
5 => On-chip ADC,
6 => CODEC
Remarks: Use this function to attach ISR to the correspondent IRQ index. To detach the ISR, just set
the isr_handler_pointer to NULL. This function is on par with Arduino Language's attachInterrupt()
and detachInterrupt() functions.
3.2.3.6 Serial
Like the Arduino Language, FP51-1T also supports Serial port as console in/out, and it supports the following
functions:
• Serial.begin()
• Serial.available()
• Serial.print()
• Serial.println()
• Serial.read()
• Serial.readBytes()
• Serial.write()
Ref [14]: PulseRain M10 – Serial Port, Technical Reference Manual, Doc# TRM-0922-01005, Rev 1.0.0,
09/2017, https://github.com/PulseRain/M10SerialAUX/raw/master/extras/M10_Serial_TRM.pdf
35 | P a g e
PulseRain FP51-1T MCU – Technical Reference Manual
3.2.4 Default Arguments for Function Call
The SDCC compiler does not support default arguments for function calls. But with the help of pre-processor
macros (Ref [16][17]), FP51-1T has managed to implement default arguments in its software libraries. The
details of the implementation can be found in the "Arduino.h" inside FP51-1T software package.
Ref [15]: PulseRain M10 – Quick Start Guide, Doc#QSG-0922-0039, Rev 1.2.0, 10/2017
https://github.com/PulseRain/Arduino_M10_IDE/blob/master/docs/M10_quick_start.pdf
And this section will discuss the technical details of the M10/FP51-1T software package for Arduino IDE.
https://github.com/PulseRain/Arduino_M10_IDE
In particular, the
https://raw.githubusercontent.com/PulseRain/Arduino_M10_IDE/master/package_M10_index.json
is the master JSON file that will provide indexes for the rest of the package, and the link above should be put
in Arduino IDE's menu: File/Preferences/Additional Boards Manager URLs, as demonstrated in Ref [15].
• The "Arduino.h" and "M10.c", which are part of the FP51 core. They contain the source code for
those APIs mentioned in Section 3.2.3.
• The "main.c", which is illustrated in Figure 3-1
• The "boards.txt" and "platform.txt". The Arduino IDE will use these two files to determine to tools
and parameters that are specific to the M10 board.
• Compiler and upload tools.
36 | P a g e
PulseRain FP51-1T MCU – Technical Reference Manual
PulseRain_M10
hardware
FP51
cores
tools
M10_compiler main.c
M10_upload
3.4 Library
As mentioned early, the FP51-1T MCU supports a variety of peripherals with open source library, and their
respective technical reference manual can be found in Ref [6][7][8][9][10][11][12][13][14]. The procedures
to install and use those libraries can be found in Ref [15].
37 | P a g e
PulseRain FP51-1T MCU – Technical Reference Manual
https://github.com/PulseRain/M10_Sketches
38 | P a g e