Posts

Showing posts with the label XC32

Interfacing a color TFT display with the PIC32MX250F128B

Image
I have been working on interfacing the PIC32MX250F128B with a small 2.2" TFT display from Adafruit. It's a nice little display that is fairly easy to communicate with, using SPI communication. The display I'm using is: http://www.adafruit.com/product/1480 Adafruit provides nice open-source libraries for their products. However, they are for Arduino and thus cannot be directly reused for the PIC32. I went through the library and ported it over for the PIC32, in C. I have attached my project file as a .zip file and you can download it to go through the library header and source files, as well as the demo code. I've tried heavily commenting the code so that it is self-explanatory. As far as hardware goes, with the demo code, the pin connections for the display are: BL (backlight): I left it unconnected, but you can connect it to 3.3V for backlight. SCK: connected to RB14 on the PIC MISO: left unconnected, since I'm not reading anything from the screen MOSI: connected ...

PIC32 SPI: Using the MCP4822 12-bit serial dual DAC

Image
I recently got a few pieces of the MCP4822 DAC. You can check out the datasheet here: http://ww1.microchip.com/downloads/en/DeviceDoc/22249A.pdf I found them to be neat little devices. In a small 8-pin PDIP package, the MCP4822 comes with 2 12-bit DACs, which you can easily configure over SPI. This was a great opportunity to get a simple PIC32 SPI application going. I worked on this today to see how fast I can get the DAC output going. Here's the pinout of the MCP4822: Fig. 1 - MCP4822 pinout (taken from datasheet) The MCP4822 can be supplied a voltage in the range of 2.7V to 5.5V. Since I use 3.3V for my PIC32, I used the same 3.3V supply for the VDD for the MCP4822. Pin 5 is the active low signal LDAC that is used to synchronize the two DAC channels. When this pin is brought low, the data in the DAC's input register is copied to the output and both outputs are updated at the same time. I just had this tied to ground. VoutA and VoutB are the two output pins. The other pins are...

PIC32MX250F128B ipl7: odd shadow register set behavior and observations

This issue has now been solved. Scroll to the bottom for the update. I started working on a pure sine wave inverter based on the PIC32MX250F128B. The first stage was to just get the SPWM working and test that before proceeding to add the power stage, feedback and other control, etc. This led me to some interesting observations regarding the PIC32MX250F128B interrupts, especially the use of the shadow register set and a related problem. I set up Timer 2 to be the time base for sine wave generation (DDS/SPWM) using OC1. In the Timer 2 interrupt, the duty cycle update request is performed (OC1RS is updated). Timer 2 interrupt priority was set to 7. This all worked fine. The initial ISR definition was: void __ISR(_TIMER_2_VECTOR, ipl7) T2int(void) { ..... } However, when I used the ADC (input from potentiometer for amplitude control - a start at implementing feedback), accessing any of the ADC registers in the while (1) loop in main stopped the PIC32 from working.  I then added ...

PIC32 Proto Board: Details, Schematic, PCB and Pictures

Image
I previously showed you my PIC32 proto board I made on verroboard ( http://electel.blogspot.com/2016/02/pic32-development-proto-board-on.html ). To make the proto board “more of a product” and easy to reproduce, I was working to make the proto board on a PCB. I used ExpressSCH to draw the schematic, and used ExpressPCB to design the PCB. Once designed, Professor Bruce Land got the PCB made from ExpressPCB themselves. The PCB is just to be a basic board with the PIC32MX250F128B placed on it. The power supply connections are provided as are external oscillator connections (if needed). Additionally, there is a nice convenient power supply input connector (standard 2.5mm jack/plug). All the IO pins along with power (Vin and +3.3V) and ground are placed on a SIL connector at the edge of the board so that the board can be conveniently placed on a breadboard for experimenting and prototyping (see pictures below). It's a nice little 2-layer PCB measuring only 3.1 inches by 1.8 inches. I c...