PIC32MX150F128 Breakout Board This is a description of a 32 Bit PIC32MX breakout board to be used for fast prototyping. It could also be used for conventional circuit boards to avoid the fine pitch of 64 pin packaged used by the device. In this case the board is piggy backed on the PCB board. A test program has been developed to verify the board and is described. The board is based on Microchip PIC32MX150F128 chip. A 44 pin TQFP packed is used. A total of 34 I/- pins are available. Bypass capacitors for power is provided on the breakout board as well as a connector for ICDA (In Circuit Emulation). The chip has the following features: 128 + 3 KB Program memory 32 KB RAM 32 remappable pins 5 Timers/Capture/Compare 2 UART 2 SPI/I2S 5 External Interrupts 3 Analog Comparators 2 I2C PMP 4 DMA Channels CTMU 13 10-bit ADC RTCC 34 I/O pins JTAG ICDA Chip pin layout is as in figure 1. The chip can use an internal RC-clock or use an external Chrystal for higher accuracy. The breakout board is prepared to use an external Chrystal. The CPU core is a DMIPS MIPS32 M4K running up to 48 MHz. The MCU has most of what you can expect from a modern microcontroller. A LED lamp indicates when power is applied. The power is 3.3 volts. The breakout board has two 22 pins 0.1 inch spaced connectors, similar to a big DIL circuit. This makes it easy to use the board on a solderless electronic prototype breadboard. All signal names are clearly visible with screened white text. An ICDA connector is mounted on the edge of the card. Via this connector you can connect a Microchip MPLAB ICD3 in circuit emulator. This gives you the possibility to download your programs to the program memory as well as debugging the program. You can set up to 6 breakpoints for this processor. One important notice! This board uses ICDA channel 2 (PGED2, PGEC2). You must enable this by a Pragma in your code as below: PIC32MX150F128 Breakout Board.docx, 2009-03-08 17:33, page: 1 (8)
// Debug Configuration #pragma config DEBUG = ON #pragma config ICESEL = ICS_PGx2 // ICE Background debugger = On. // Note, you must do this due to that com port #2 is used for ICS Figure 1, Pin layout of the PIC32 chip used (PIC32MX150F128D) The schematic is shown in figure 2. Note that C7, C8 X1 is optional. They are only used if you want to have a crystal based CPU clock. In most cases it will work without problem to use the on chip RC-clock. Use low ESR capacitors. The colors on the ICDA pin is the standard colors I use for my own cables and just a reminder. Be careful to connect with the right polarity, NMCLR must be connected to pin 1 of the ICDA connector. All ports are only labeled with their port name (A, B, C) and the pin name. You can use the cross table found in Microchip data sheet for the processor to find the other corresponding signals that are shared with a port. Bear also in mind that PIC32MX150FXX uses Peripheral Pin Select (PPS), you can decide by configuration commands which signal shall be assigned to a particular pin. In total we have 35 I/O pins that can be used, not including NMCLR (Clear/Reset signal). PIC32MX150F128 Breakout Board.docx, 2009-03-08 17:33, page: 2 (8)
Figure 2, schematic of the board. The pin configuration can be seen in table 1. J-Conn Jax-Pin DIL-pin Signal JA1 1 1 RB15/AN9_SCK2 JA1 2 2 RB14_AN10_SCK1 JA1 3 3 RB13_AN1 JA1 4 4 RB12 JA1 5 5 RB11_PGEC2 JA1 6 6 RB10_PGED2 JA1 7 7 RB9 JA1 8 8 RB8 JA1 9 9 RB7_INT0 JA1 10 10 RB6_SCL2 JA1 11 11 RB5_SDA2 JA1 12 12 RB4 JA1 13 13 RB3_AN5 JA1 14 14 RB2_AN4 JA1 15 15 RB1_AN3_PGEC1 JA1 16 16 RB0_AN2_PGED1 JA1 17 17 RA10 JA1 18 18 RA9 JA1 19 19 RA8 JA1 20 20 RA7 JA1 21 21 RA4_T1CK JA1 22 22 RA3_OSC2 J-Conn Jax-Pin DIL-pin Signal JA2 1 23 RA2_OSC1 JA2 2 24 RA1_AN1_SCL1 JA2 3 25 RA0_AN0_SDA1 JA2 4 26 RC0_AN6 JA2 5 27 RC1_AN7 JA2 6 28 RC2_AN8 JA2 7 29 RC3 JA2 8 30 RC4 JA2 9 31 RC5 JA2 10 32 RC6 JA2 11 33 RC7 JA2 12 34 RC8 JA2 13 35 RC9 JA2 14 36 NMCLR JA2 15 37 NC JA2 16 38 NC JA2 17 39 Vdd+3.3V JA2 18 40 Vdd+3.3V JA2 19 41 Vdd+3.3V JA2 20 42 GND JA2 21 43 GND JA2 22 44 GND PIC32MX150F128 Breakout Board.docx, 2009-03-08 17:33, page: 3 (8)
Table 1, Breakout Board Pin configuration Note that some signals can t be used with PPS and are bound to a particular I/O pin. These are included in table 1. In figure 3 you can see a computer generated 3D picture of the board (top side) Figure 3, Computer generated 3D picture of the board A photo of the breakout board can be seen in figure 4. In this case the internal RC generator is used to provide the internal clock. This simple setup was used for the initial test to check that the board was preforming as expected. Figure 1, PIC32MX150F128D Breakout board connected to MPLAB ICD 3 Test Program A test program was made for the board. The purpose was just to check that the basic functions where working correctly. Besides doing some simple outputs it also checks the CPU and the on chip RAM. The pragma section can be of particular interest, se figure below. // System clock selection #pragma config FNOSC = FRCPLL #pragma config FPLLIDIV = DIV_2 #pragma config FPLLMUL = MUL_24 #pragma config FPLLODIV = DIV_2 #pragma config FPBDIV = DIV_2 #pragma config FSOSCEN = OFF // Watchdog Configuration #pragma config FWDTEN = OFF #pragma config WDTPS = PS1048576 // RC OSC 8 MHz // Divide 8/2 to get 4 MHz // Multiply by 24 to get 96 MHZ // Divide 96/2 to get 48 MHz System Clock // Peripheral Clock Divisor gives 24 MHz // Must be off to use RB4 // Watchdog Timer Enable bit, Watchdog OFF. // Watchdog Timer Postscale Select bits, WDPS = Max. PIC32MX150F128 Breakout Board.docx, 2009-03-08 17:33, page: 4 (8)
// Debug Configuration #pragma config DEBUG = ON #pragma config ICESEL = ICS_PGx2 // Memory Configuration #pragma config CP = OFF #pragma config BWP = OFF #pragma config PWP = OFF // ICE Background debugger = On. // Note, you must do this due to that com port #2 is used for ICS // Code Protect Disabled. // Boot Flash write protect OFF. // Program Flash write protect OFF. #define SYS_CLK_MHZ 48 #define SYS_CLK_HZ 48000000L Note that this will give an infernal RC clock with a frequency of 48 MHz (20.8333 ns). I must admit that I actually wanted to have a 50 MHz clock but couldn t figure out how to get that figure. Perhaps somebody reading this can give an advice. A simple test program was developed. It uses one LED as an output indicator. The LED shall be connected to pin RC0 via a 470 ohms resistor. During the test the diode will blink fast. If the test is successful it will lit the LED with a steady green light for a while. It will after a delay start the sequence all over again. If it fails the LED will be turned off. The test program outputs the oscillator frequency (System Clock/SYSCLK) on pin RC3. You can easily verify this by connecting an oscilloscope to the pin. You will get a wave form as in figure YY. The test circuit setup is shown in figure x. Figure 5, test setup with the bread board PIC32MX150F128 Breakout Board.docx, 2009-03-08 17:33, page: 5 (8)
You will see the LED blinking rapidly for a while then become steady lit up and the go back to the blinking. During steady lit the CPU test program is executing. You can see the pulse at RC0 with an oscilloscope. On pin RC2 you will find a square wave. On RC3 you will find the CPU clock, see more below. Finally, on pin RB4 you will see a PWM signal, OC1. When using a PIC32MX150F128D MCU and outputting the REFCLKO signal to a port pin I get the waveform as in the figure below. The remarkable thing is that it has negative voltage swing and that it looks like a sinus. I expected the signal to be pure square and just a positive voltage swing above ground. Figure 6, REFCLKO signal at pin RC3, note the negative swing The small red doted horizontal line is the ground reference level. As can be seen from the figure the max is 3.125 Volt and the min -2.313 Volts. I did check the ground reference level with another signal. It is correct! I m confused of this behavior. Does anybody have experience of this behavior and can explain it? How can the signal be negative? CPU and RAM test functions The following test functions are within the test framework: DoCpuRegisterTest(); DoProgramCounterTest(); DoCheckerBoardRamTest(); DoMarchBRamTest(); DoMarchCRamTtests(); DoMarchCMinusRamTtest(); DoMarchCRamAndStackTest(); DoFlashCrcTest(); PIC32MX150F128 Breakout Board.docx, 2009-03-08 17:33, page: 6 (8)
DoCpuRegisterTest(); This function tests the 31 CPU Registers. This is a non-destructive test. Interrupts should be disabled when calling this test function. DoProgramCounterTest(); This is a functional test of the Program Counter (PC). It checks that the PC register is not stuck and it properly holds the address of the next instruction to be executed. DoCheckerBoardRamTest(); This function implements the Checkerboard test on the RAM memory. This is a non-destructive memory test. The content of the tested memory area is saved and restored. The test operates in 64 bytes long memory chunks at a time. DoMarchBRamTest(); This function implements the March B test. This test performs 32-bit word RAM accesses. The address of the RAM area to be tested must be 32-bit aligned and the size of the tested RAM area must be an integral multiple of 4. The tested RAM memory will be cleared when the control returns so this is a destructive memory test. DoMarchCRamTtests(); This function implements the March C test. This test performs 32-bit word RAM accesses. The address of the RAM area to be tested must be 32-bit aligned and the size of the tested RAM area must be an integral multiple of 4. This is a destructive memory test. DoMarchCMinusRamTtest(); This function implements the March C Minus test. This test performs 32-bit word RAM accesses. The address of the RAM area to be tested must be 32-bit aligned and the size of the tested RAM area must be an integral multiple of 4. This is a destructive memory test. DoMarchCRamAndStackTest(); This function implements the March C test on both a RAM and a stack area. First the RAM area is tested using the standard March C test. If the test succeeded the requested Stack area is copied into the RAM area that has just been tested and then the March C test is run over the Stack area as if it were a regular RAM area. The saved Stack area is restored and the result of the test is returned to the user. Once the Stack area is tested, the SP register is restored. This is a destructive memory test. DoFlashCrcTest(); This function calculates the 16-bit CRC of the supplied memory area using the standard Linear Feedback Shift Register (LFSR) implementation. It calculates the CRC over the memory area between the start address and end address and returns the CRC Value. This test is non-destructive for the memory area to which it is applied. The above test functions use a bit structure to set the result of each individual test, se below: volatile struct ClassB_Test_Flags { unsigned cpuregister_testresult : 1; PIC32MX150F128 Breakout Board.docx, 2009-03-08 17:33, page: 7 (8)
unsigned programcounter_testresult:1; unsigned checkerboardram_testresult:1; unsigned marchcram_testresult:1; unsigned marchcminusram_testresult:1; unsigned marchcramstack_testresult:1; unsigned marchbram_testresult:1; unsigned flash_testresult:1; unsigned clock_testresult:1; unsigned clockline_testresult:1; } testflag; If the specific test has passed the corresponding bit is set to True (1), if it fails it will be set to False (0). Note that the two last bits for clock tests are not implemented in this incarnation. If the LED will be switched off, indicating an error, of check these bits for the probably cause. The memory test program uses malloc to allocate memory. Therefore it s important to set up the Heap due to the fact that malloc the heap to acquire memory. To set up the heap see figure 7 as an example. Note also that the stack size is set as well. Figure 7, Project build options to get a Heap Note that this project was developed and compiled using MPLAB IDE V8.92. However it should be rather straight forward to import it to the new MPLAB XC development environment. Regards Bo, SM6FIE References 1. Circuit diagram, pdf file 2. PCB DXF files, zip file 3. Test Framework, zip file Keywords: PIC32, PIC32MX150, Breakout Board, PIC32 Test program, REFCLKO, Class B Test software, Microchip PIC MCU PIC32MX150F128 Breakout Board.docx, 2009-03-08 17:33, page: 8 (8)