Memory

Creating Large Memory Arrays The C18 compiler does not support data buffers over 256 bytes without a modification to the linker script to define a larger bank of microcontroller ram. Copy the default linker script for your PIC18 device from: C:\Program Files (x86)\Microchip\MPASM Suite\LKR into your projects directory.  Add the file to your MPLAB project so […]

Read More

Example IRQ Handler

  //************************************************ //************************************************ //********** INTERRUPT SERVICE ROUTINES ********** //************************************************ //************************************************ //********************************************** //********************************************** //********** HIGH PRIORITY INTERRUPTS ********** //********************************************** //********************************************** void interrupt my_high_priority_irq_handler(void) { //if (TMR0IE && TMR0IF) //{ // TMR0IF=0; // return; //} // process other interrupt sources here, if required } //********************************************* //********************************************* //********** LOW PRIORITY INTERRUPTS ********** //********************************************* //********************************************* void interrupt low_priority my_low_priority_irq_handler(void) […]

Read More

AtoD

Register Based Working Example Set up AtoD //—– SETUP AtoD —– AD1PCFG = 0xFFFC; //AN1:0 analog, reset digital AD1CHSbits.CH0SA = 0; //Channel 0 positive input is AN0 AD1CON1bits.SSRC = 7; //Internal counter ends sampling and starts conversion (auto-convert) AD1CON1bits.ASAM = 1; //Sampling begins when SAMP bit is set //The PIC32 can sample up to 1000ksps, […]

Read More

.Changes From MPLAB

Combining Hex Files For Bootloader Projects etc In MPLAB you could export a specific memory areas only hex file from a bootloader project and then use this: Menu > Configure > Settings > Program Loading > 'Clear program memory uploading a program' to import it into the main project so the hex files became combined.  You […]

Read More

SPI – PIC18

  //—– SETUP SSP1 —– //Used for: //CLK idle in low state //AT45DB081 clocks in data on the rising edge, outputs data on the falling edge SSPSTAT = 0b01000000; SSPCON1 = 0b00100000; //Fosc / 4 = 10MHz    

Read More

SPI

SPI Master //—– SETUP SPI 1 —– //Used for: w_temp = SPI1BUF; SPI1STAT = 0; SPI1CON1 = 0b0000001100100001; //SPI in master mode (SPI1STATbits.SPIEN must be 0 to write to this register) //Data is valid on the rising edge of the clock (Transmit occurs on transition from active to idle clock state) //Clock low in idle […]

Read More