I'm trying to configure the readily available Nokia 5110 LCD (see Sparkfun's website for more info) using SPI communication lines from a Nucleo L476RG board. According to the datasheet for the LCD, there is an initialization procedure that must be followed before the device can display properly. I've coded up that init routine in VS2017 which is provided below. The issue lies with lines in bold; when the charge pump voltage is set to a non-zero value (charge pump enabled), the board resets following the associated call to SPI_transmit. (The charge pump voltage controls contrast on the LCD) My first assumption is that this is due to an overcurrent fault caused by activation of the charge pump, but I'm not certain and don't know how to remediate the problem. Am I way off base? Irregardless is there a step I'm missing? I can provide a pinput of the connections if that helps resolve the issue. Thanks in advance!
void initLCD(SPI_HandleTypeDef* spi)
{
//Initialize LCD routine
uint8_t tx_byte;
HAL_Delay(10);
//Deassert LCD reset pin
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_10, GPIO_PIN_SET);
//Set VLCD High (3.3 V)
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_5, GPIO_PIN_SET);
w
HAL_Delay(10);
//assert SCLK Enable
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_6, GPIO_PIN_RESET);
HAL_Delay(2);
//Switch to Command Mode
HAL_GPIO_WritePin(GPIOC, GPIO_PIN_7, GPIO_PIN_RESET);
//PD = 0, V = 0, Extended Instruction Set (H=1 mode)
tx_byte = 0x21;
HAL_SPI_Transmit(spi, &tx_byte, sizeof(tx_byte), HAL_MAX_DELAY);
//Set Vop (charge pump voltage) to 3 + (16 X 0.06) (V)
tx_byte = 0x90;
HAL_SPI_Transmit(spi, &tx_byte, sizeof(tx_byte), HAL_MAX_DELAY);
//set bias system to 1:48
tx_byte = 0x13;
HAL_SPI_Transmit(spi, &tx_byte, sizeof(tx_byte), HAL_MAX_DELAY);
//PD = 0, V = 0, Normal Instruction Set (H=0 mode)
tx_byte = 0x20;
HAL_SPI_Transmit(spi, &tx_byte, sizeof(tx_byte), HAL_MAX_DELAY);
//Display Normal Mode (DE = 10)
tx_byte = 0x0C;
HAL_SPI_Transmit(spi, &tx_byte, sizeof(tx_byte), HAL_MAX_DELAY);
//deassert SCLK Enable
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_6, GPIO_PIN_SET);
HAL_Delay(2);
}