jagnala

Members
  • Content count

    5
  • Joined

  • Last visited

  1. Some good news, its seem the issue is not with the SPI communication, I can configure the contrast and other setting on the display I can see the pattern increase and decrease in brightness. The display also only turns on when I send the Spi2PutByte(0xAF); command so i'm sure messages are being received. I feel like i'm getting close to the issue.
  2. I've run the clock at 8Mhz and below with so change in results also, I'm using SPI1 for my application. I saw I posted SPI2STATbits.SPIROV = 0; but its SPI1STATbits.SPIROV = 0; in my code. Thanks for the hit but still no luck.
  3. Thank for the tip but no luck so far. But I'll keep troubleshooting. If you think of anything else please let me know. Thanks
  4. Sure, see the snippet below for the PmodOLED that I've updated: I'm using MPLABSX XC16 void OledHostInit() { // Initialize SPI port 2. /* The following code sequence shows SPI register configuration for Master mode */ IFS0bits.SPI1IF = 0; // Clear the Interrupt flag IEC0bits.SPI1IE = 0; // Disable the interrupt // SPI1CON1 Register Settings SPI1CON1bits.DISSCK = 0; // Internal serial clock is enabled SPI1CON1bits.DISSDO = 0; // SDOx pin is controlled by the module SPI1CON1bits.MODE16 = 0; // Communication is word-wide (16 bits) SPI1CON1bits.MSTEN = 1; // Master mode enabled SPI1CON1bits.SMP = 0; // Input data is sampled at the middle of data output time SPI1CON1bits.CKE = 0; // Serial output data changes on transition from SPI1CON1bits.PPRE = 0b11; SPI1CON1bits.SPRE = 0b000; SPI1CON1bits.SSEN = 0; SPI1CON2 = 0; // Idle clock state to active clock state SPI1CON1bits.CKP = 1; // Idle state for clock is a low level; // active state is a high level SPI2STATbits.SPIROV = 0; SPI1STATbits.SPIEN = 1; // Enable SPI module // Interrupt Controller Settings IFS0bits.SPI1IF = 0; // Clear the Interrupt flag IEC0bits.SPI1IE = 1; // Enable the interrupt /* Make power control pins be outputs with the supplies off */ bitVddCtrl = true; bitVbatCtrl = true; /* Make the Data/Command select, Reset, and SPI CS pins be outputs. */ bitDataCmd = true; bitReset = true; bitSelect = true; } void OledPutBuffer(int cb, unsigned char * rgbTx) { int ib; unsigned char bTmp; /* Bring the slave select line low */ bitSelect = false; DelayMS(10); /* Write/Read the data */ for (ib = 0; ib < cb; ib++) { /* Wait for transmitter to be ready */ while (SPI1STATbits.SPITBF != 0); /* Write the next transmit byte. */ SPI1BUF = *rgbTx++; /* Wait for receive byte. */ while (SPI1STATbits.SPIRBF == 0); bTmp = SPI1BUF; } /* Bring the slave select line high */ bitSelect = true; DelayMS(10); } unsigned char Spi2PutByte(unsigned char bVal) { unsigned char bRx; /* Bring the slave select line low */ bitSelect = false; DelayMS(10); while (SPI1STATbits.SPITBF != 0); /* Write the next transmit byte. */ SPI1BUF = bVal; /* Wait for receive byte. */ while (SPI1STATbits.SPIRBF == 0); /* Put the received byte in the buffer. */ bRx = SPI1BUF; /* Bring the slave select line high */ bitSelect = true; DelayMS(10); return bRx; } Thanks so much
  5. Hi, I'm trying to get the Pmod OLED to work with the PIC24F32KA302, I've used the template file and modified all the register appropriately but I cant get the display to work. It turns on and always display garbage when I try writing to it and even clear the OLED doesn't seem to work, the display does respond to SPI command but just the displays different just pixels. any thoughts on what might be wrong, I can post some code if it helps.