SPI

Master SPI Port Initialise #define INTERBOARD_COMMS_SS_PIN LATDbits.LATD3 #define INTERBOARD_COMMS_PACKET_LENGTH 10 //—– SETUP SSP2 AS SPI BUS —– //Used for: //CLK idle in low state //Devices clock in data on the rising edge, output data on the falling edge SSP2STAT = 0b11000000; SSP2CON1 = 0b00100010; //16MHz Fosc / 64 = 250000kHz //—– INIT SPI —– //Send […]

Read More

Assembler

ISSUE – Destination and RAM access bit specified This used to be requried for asm code when you wanted to tell it the ,d and ,a bits of the instruction: near static unsigned char uc_asm_irq_temp; // near qualifier specifies access RAM near static unsigned char uc_asm_irq_temp1; movlw 0xcb addwf _uc_asm_irq_temp,f,c //(1 = file register, 0 = […]

Read More

PWM

  PWM Setup PWM Period = [(PR2) + 1] x 4 x TOSC x (TMR2 Prescale Value) PWM Duty Cycle = (CCPR4L:CCP4CON<5:4>) x TOSC x (TMR2 Prescale Value)   So your PWM period is adjustable using an 8bit PR# value and a 2 bit timer prescaller value (x1, x4, x16) and is based on the instruction clock speed (4 […]

Read More