Hello,
I'm new to the MSP430 so apologies if this a stupid question.
Here is my setup,
DCO at 8MHz
MCLK at 8MHz (1x divider)
SMCLK at 4MHz (2x divider from DCO)
I2C SCL at 100kHz (auto divider)
The SMCLK is used for an external camera and P3.4 is used to output SMCLK to the camera.
The camera is triggered by writing a register through I2C, at that point the camera raises a pin to indicate a frame is starting and that triggers a DMA transfer from the 3 output pins of the camera to FRAM. The camera outputs a pixel clock which is used as DMAE0. The camera trigger is initiated by a button press.
Here is some pseudo-code:
main()
{
init_clocks();
init_GPIO();
init_i2c();
init_camera();
__enable_interrupt();
while(1)
{
if(img_capturing == 1)
{
_low_power_mode_0();
}
else
{
_low_power_mode_2();
}
if(trig_camera)
{
trigger_camera();
trig_camera = 0;
img_capturing = 1;
}
if(image_ready)
{
//do something
img_capturing = 0;
image_ready = 0;
}
}
} //main()
// This is the ISR for the VSYNC signal
__interrupt void PORT8_ISR()
{
setup_DMA_transfer();
enable_transfer();
}
// ISR to know when the transfer is done
__interrupt void DMA_ISR()
{
image_ready = 1;
disable_DMA_interrupt();
__low_power_mode_off_on_exit();
}
//ISR for the button that triggers the camera
__interrupt void buttonIsrHandler(void)
{
switch (__even_in_range(P5IV, P5IV_P5IFG7))
{
case P5IV_P5IFG6:
trig_camera = 1;
__low_power_mode_off_on_exit();
break;
default: break;
}
}
Without using the low power modes everything works fine.
But when I add the management of low power modes as above, the camera is not responding. The VSYINC signal that is generated by the camera, goes high and never goes low again.
My idea is to stay in LPM2 (or lower) when the camera is not taking any pictures (standby). After the camera has been triggered however the chip needs to stay in LPM0 in order to generate the SMCLK that the camera needs. The camera does not need a clock when is in standby so it should be fine if the SMCLK is stopped while not taking pictures.
A strange thing perhaps is that If I add a breakpoint at the line (image_ready = 0;) in the main loop then the code seems to work, every time I press the button the camera is triggered fine. It seems there is some race condition which does not occur if the execution stops for the breakpoint.
What am I missing?
Thanks