When I debug the code, the LCD refreshes rapidly. I am not confident with the correct system clock configuration to use. Here's the connection for the external crystal: Schematic The specs of my custom LCD are:
Operation Method: 1/4 duty, 1/3 bias // Frame Frequency: 32Hz // Operating Voltage: 3V
This is my code for initialization: void initialize(void)
{
WDTCTL = WDTPW | WDTHOLD | 0x20;
SCFI0 = 0xC0; // FLLDx = 11 FLL Divider = 1/8
FLL_CTL0 = 0x30; // 0011 0000 enable DCOPLUS+enable 10pFinternal crystal cap
for (i = 60000; i>0; i--); // Delay for 32 kHz crystal to stabilize// Initialize LCD
SCFQCTL = 0x0F; // 1111BTCTL = 0x33; // 0011 0011
LCDCTL = 0x5D; // 0101 1101
}
In setting the f(LCD), I have 4-mux and f(Frame) = 32Hz, so that would min fLCD = 256Hz. So in BTFRFQx bits and BTIPx bits, I am not sure what should I set.
I am thinking that maybe it is in SCFI0 that causes the problem? As I haven't run any code to my MCU but the LCD when powered up by the JTAG debugger is already flickering at the start. I am having struggle with how should I set the correct clock configuration as my only specs to look at is that the frame rate of my LCD is 32Hz and my external watch crystal is 32kHz.
This is what I want to run test
volatile unsigned int count = 0; // init count variable
#define TOGGLE_LED() P2OUT ^= BIT4;
void GPIO_init(){
P2DIR |= BIT4; // Set P1.4 (LED) as output
P2OUT &= ~BIT4; // Turn off the LED initially
P1DIR &= ~BIT2; // Set P1.2 (button) as input
P1IES |= BIT2; // Set interrupt on falling edge (button press)
P1IE |= BIT2; // Enable interrupt for P1.1
P1IFG &= ~BIT2; // Clear P1.1 interrupt flag }
#pragma vector=PORT1_VECTOR
__interrupt void Port1_ISR(void)
{
// Check if the interrupt is from P1.1 (button press)
if ((P1IN & BIT2) == 0)
{
count++;
if (count >999){
count = 0; // Reset to 0 after reaching 9
}
clearDisplay();
updateDisplay(count);
TOGGLE_LED(); // Toggle the LED
P1IFG &= ~BIT2; // Clear the interrupt flag for P1.1
}
}
int main(void)
{
initialize();
GPIO_init();
__enable_interrupt();
while(1) {}
}