SPI – PIC32

SPI Master //—– SETUP SPI 1 —– //Used for: //Idle low, active high //Transmit on active to idle (falling edge) SpiChnOpen(SPI_CHANNEL1, (SPI_CON_MSTEN | SPI_OPEN_CKE_REV | SPI_CON_MODE8), 2); //40MHz fpb / 2 = 20MHz SPI Slave #define COMMS_SPI_NAME SPI_CHANNEL3 #define COMMS_SPI_ID SPI_CHANNEL3 #define COMMS_SPI_SS_PIN_STATE mPORTEReadBits(BIT_8) //—– SETUP SPI 3 —– //Used for: (we are slave with […]

Read More →

Watch

Setting Default Watch Value Format Click the '$' button at the left of the watch window.  

Read More →

I2C

  //—– SETUP I2C 1 —– //Used for: EEprom w_temp = I2C1RCV; I2C1ADD = 0; I2C1BRG = 395; //157=100KHz@16MIPS, 395=100KHz@40MIPS (typically 100kHz, 400kHz or 1MHz) I2C1STAT = 0; I2C1CON = 0; I2C1CONbits.I2CEN = 1; //Enable I2C          

Read More →

Include

Both of these are fine: #include "display_files/output/display_files_c.h" #include "display_files\output\display_files_c.h"    

Read More →

Debugger Won’t Work

"The target device is not ready for debugging. Please check your configuration bit settings and program the device before proceeding." If you device has multiple debugger connection / comm channel pins check the correct pair is selected in the configuration bits

Read More →

MPLAB X Configuration

These are things we change from the default setup to make MPLABX behave the way we like… Turning Off right margin red line Menu > Tools > Options > Editor > Formatting Language: All Languages Right margin: 0 Turning Off Expand Tabs To Spaces setting Menu > Tools > Options > Editor > Formatting Language: […]

Read More →

Configuration Bits, SFR’s, etc

  Menu > Window > PIC Memory Views > Configuration Bits Getting available config settings for a device Get the config fields from the "C:\Program Files (x86)\Microchip\MPASM Suite" .inc file for the device

Read More →