STM32-H103 + CMOS Camera (Samsung e700)

HI, I have Olimex STM32-H103 Dev. board with Cotex-M3 chip on board. I want to connect CMOS Camera from Samsung E700 (http://www.sparkfun.com/commerce/produc … cts_id=637). And I have several questions:

  1. Dev. board get power supply from USB (5V), on board I have 5V & 3.3V, but CMOS Camera needs 2.9-3.0V. Can I get power from 3.3V(EXT1-5, EXT1-6) via 10k resistor for camera?

2)I need I2C communication b/w camera & MCU, should I use pull-up resistor (connected to +3.3 or +5V)?

So, I have on the breakout board:

  • 10k Resistor connected on GND wire b/w camera & STM32

  • Decoupling capacitors (0.1µF MKT)

  • Pull-up resistors (10k) connected to SCL, SDA & +3V

My connection scheme is:

SCL → PB6

SDA → PB7

MCLK → PB8

HSYNC → PC0

VSYNC → PC1

PCLK → PC2

\ENB → PC10

\RST → PA10

DATA[0…7]->PA[0…7]

RST and ENB are driven high. In camera manual from SFE by David says that ENB 11 pin & /RST 12 pin, but I found in inet (http://o-d-v.nm.ru/tel_cam/cameras/samsung_E700.htm) that /RST is 11 & /ENB 12 :?: :!:

STM32 generate clock via TIM4(PB8)

It won’t respond over I2C either. Just want to read some registr (device ID)

/Generate Start/

I2C_GenerateSTART(I2C1, ENABLE);

while(!I2C_CheckEvent(I2C1, I2C_EVENT_MASTER_MODE_SELECT));

/Send slave address/

I2C_Send7bitAddress(I2C1, 0x22, I2C_Direction_Transmitter);

while(!I2C_CheckEvent(I2C1, I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED));//stops here forever ??

Looks like problem in power supply. Voltmetr shows 1.5V on camera (b/w GND & Vcc). 10K is too much.

Also I used 5-10cm wires b/w camera and mcu.

So, what is the best way to get proper power supply: resistor, volt regulator, zener diode, ferrite bead

I have wrote a test application to my samsung E700 camera and it doesn’t work ( i can si continuously the same sign) And Dave wrote that it should send images without any configuration. Maybe somebody has a idea what is wrong. OR someone can share code with me please. Here is my not really sophisticated code. I repeat it is only test.

PA0…7-Data

PA8 Clock output (8Mhz)

PB2 – Reset

PB3- Enable

Rest is not needed for my application.

Here it is:

#include "stm32f10x.h"
#include "lcd4bit.h"

void RCC_Conf(void);
void GPIO_Conf(void);
void NVIC_Conf(void);

void delay(int del)
{
	int i, tmp;
	tmp = 9000*del;
	for(i=0;i<tmp;i++);
}

int main(void)
{ 
 uint8_t Odczyt=0, setki, dziesiatki, jednosci,i; 
#ifdef DEBUG
  debug();
#endif	 
  	RCC_Conf();   
  	NVIC_Conf();
  	GPIO_Conf();

	LCD_Init();
	LCD_Clear();
	GPIO_SetBits(GPIOB,GPIO_Pin_3);//wlacz kamerke
	GPIO_ResetBits(GPIOB,GPIO_Pin_2);  //reset
	delay(100);
	GPIO_SetBits(GPIOB,GPIO_Pin_2);	   
	GPIO_SetBits(GPIOB,GPIO_Pin_3);//jeszcze raz wlacz jakby co
  	while (1)
	{
	for(i=0;i<4;i++	)
	{
	 if(GPIO_ReadInputDataBit(GPIOA, GPIO_Pin_7))	//odczyt bajtu danych (kurde jak inaczej)
		Odczyt |= 0x80;
	if(GPIO_ReadInputDataBit(GPIOA, GPIO_Pin_6))
		Odczyt |= 0x40; 
	if(GPIO_ReadInputDataBit(GPIOA, GPIO_Pin_5))
		Odczyt |= 0x20; 
	if(GPIO_ReadInputDataBit(GPIOA, GPIO_Pin_4))
		Odczyt |= 0x10;  
	if(GPIO_ReadInputDataBit(GPIOA, GPIO_Pin_3))	
		Odczyt |= 0x08;
	if(GPIO_ReadInputDataBit(GPIOA, GPIO_Pin_2))
		Odczyt |= 0x04; 
	if(GPIO_ReadInputDataBit(GPIOA, GPIO_Pin_1))
		Odczyt |= 0x02; 
	if(GPIO_ReadInputDataBit(GPIOA, GPIO_Pin_0))
		Odczyt |= 0x01;  
	 /*setki=(Odczyt/100)+48  ;
	 Odczyt=Odczyt-setki*100;
	 dziesiatki=(Odczyt/10)+48;
	 Odczyt=Odczyt-dziesiatki*10;
	 jednosci=Odczyt+48; 
	 LCD_SendData(setki);
	 LCD_SendData(dziesiatki);
	 LCD_SendData(jednosci);	*/
	 LCD_SendData(Odczyt);
	 LCD_SendData(' ');
	 delay(1000);
	 Odczyt=0;
	 }
	  LCD_Clear();
	}
}

void RCC_Conf(void)
{  
  ErrorStatus HSEStartUpStatus; 
  // Reset ustawien RCC
  RCC_DeInit();
  // Wlacz HSE
  RCC_HSEConfig(RCC_HSE_ON);
  // Czekaj za HSE bedzie gotowy
  HSEStartUpStatus = RCC_WaitForHSEStartUp();
  if(HSEStartUpStatus == SUCCESS)
  {
    FLASH_PrefetchBufferCmd(FLASH_PrefetchBuffer_Enable);
    // zwloka dla pamieci Flash
    FLASH_SetLatency(FLASH_Latency_2);
    // HCLK = SYSCLK
    RCC_HCLKConfig(RCC_SYSCLK_Div1); 
    // PCLK2 = HCLK
    RCC_PCLK2Config(RCC_HCLK_Div1); 
    // PCLK1 = HCLK/2
    RCC_PCLK1Config(RCC_HCLK_Div2);
    // PLLCLK = 8MHz * 9 = 72 MHz
    RCC_PLLConfig(RCC_PLLSource_HSE_Div1, RCC_PLLMul_9);
    // Wlacz PLL 
    RCC_PLLCmd(ENABLE);
    // Czekaj az PLL poprawnie sie uruchomi
    while(RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET);
    // PLL bedzie zrodlem sygnalu zegarowego
    RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);
    // Czekaj az PLL bedzie sygnalem zegarowym systemu
    while(RCC_GetSYSCLKSource() != 0x08);
  }
    RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);
	RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE);
}

void GPIO_Conf(void)
{
  	GPIO_InitTypeDef GPIO_InitStructure;

  	GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3| GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_6 | GPIO_Pin_7;
  	GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
  	GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  	GPIO_Init(GPIOA, &GPIO_InitStructure);
	
	GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8;		   //zegar
  	GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
  	GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  	GPIO_Init(GPIOA, &GPIO_InitStructure);	
	RCC_MCOConfig(RCC_MCO_HSE);//wystawienie sygnalu zegarowego HSE dla kamerki 
	 

	GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3|| GPIO_Pin_2;			//EN  oraz reset
  	GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
  	GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  	GPIO_Init(GPIOB, &GPIO_InitStructure);
  	
}

Thats all : ) bye !

Hi, after a quick look at your code I have observed that you have to replace logically OR (||) with bitwise OR(|) in the configuration of PORT B.

cool_kuba:
I have wrote a test application to my samsung E700 camera and it doesn’t work ( i can si continuously the same sign) And Dave wrote that it should send images without any configuration. Maybe somebody has a idea what is wrong. OR someone can share code with me please. Here is my not really sophisticated code. I repeat it is only test.

PA0…7-Data

PA8 Clock output (8Mhz)

PB2 – Reset

PB3- Enable

Rest is not needed for my application.

Here it is:

#include "stm32f10x.h"

#include “lcd4bit.h”

void RCC_Conf(void);
void GPIO_Conf(void);
void NVIC_Conf(void);

void delay(int del)
{
int i, tmp;
tmp = 9000*del;
for(i=0;i<tmp;i++);
}

int main(void)
{
uint8_t Odczyt=0, setki, dziesiatki, jednosci,i;
#ifdef DEBUG
debug();
#endif
RCC_Conf();
NVIC_Conf();
GPIO_Conf();

LCD_Init();
LCD_Clear();
GPIO_SetBits(GPIOB,GPIO_Pin_3);//wlacz kamerke
GPIO_ResetBits(GPIOB,GPIO_Pin_2);  //reset
delay(100);
GPIO_SetBits(GPIOB,GPIO_Pin_2);	   
GPIO_SetBits(GPIOB,GPIO_Pin_3);//jeszcze raz wlacz jakby co
while (1)
{
for(i=0;i<4;i++	)
{
 if(GPIO_ReadInputDataBit(GPIOA, GPIO_Pin_7))	//odczyt bajtu danych (kurde jak inaczej)
	Odczyt |= 0x80;
if(GPIO_ReadInputDataBit(GPIOA, GPIO_Pin_6))
	Odczyt |= 0x40; 
if(GPIO_ReadInputDataBit(GPIOA, GPIO_Pin_5))
	Odczyt |= 0x20; 
if(GPIO_ReadInputDataBit(GPIOA, GPIO_Pin_4))
	Odczyt |= 0x10;  
if(GPIO_ReadInputDataBit(GPIOA, GPIO_Pin_3))	
	Odczyt |= 0x08;
if(GPIO_ReadInputDataBit(GPIOA, GPIO_Pin_2))
	Odczyt |= 0x04; 
if(GPIO_ReadInputDataBit(GPIOA, GPIO_Pin_1))
	Odczyt |= 0x02; 
if(GPIO_ReadInputDataBit(GPIOA, GPIO_Pin_0))
	Odczyt |= 0x01;  
 /*setki=(Odczyt/100)+48  ;
 Odczyt=Odczyt-setki*100;
 dziesiatki=(Odczyt/10)+48;
 Odczyt=Odczyt-dziesiatki*10;
 jednosci=Odczyt+48; 
 LCD_SendData(setki);
 LCD_SendData(dziesiatki);
 LCD_SendData(jednosci);	*/
 LCD_SendData(Odczyt);
 LCD_SendData(' ');
 delay(1000);
 Odczyt=0;
 }
  LCD_Clear();
}

}

void RCC_Conf(void)
{
ErrorStatus HSEStartUpStatus;
// Reset ustawien RCC
RCC_DeInit();
// Wlacz HSE
RCC_HSEConfig(RCC_HSE_ON);
// Czekaj za HSE bedzie gotowy
HSEStartUpStatus = RCC_WaitForHSEStartUp();
if(HSEStartUpStatus == SUCCESS)
{
FLASH_PrefetchBufferCmd(FLASH_PrefetchBuffer_Enable);
// zwloka dla pamieci Flash
FLASH_SetLatency(FLASH_Latency_2);
// HCLK = SYSCLK
RCC_HCLKConfig(RCC_SYSCLK_Div1);
// PCLK2 = HCLK
RCC_PCLK2Config(RCC_HCLK_Div1);
// PCLK1 = HCLK/2
RCC_PCLK1Config(RCC_HCLK_Div2);
// PLLCLK = 8MHz * 9 = 72 MHz
RCC_PLLConfig(RCC_PLLSource_HSE_Div1, RCC_PLLMul_9);
// Wlacz PLL
RCC_PLLCmd(ENABLE);
// Czekaj az PLL poprawnie sie uruchomi
while(RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET);
// PLL bedzie zrodlem sygnalu zegarowego
RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);
// Czekaj az PLL bedzie sygnalem zegarowym systemu
while(RCC_GetSYSCLKSource() != 0x08);
}
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE);
}

void GPIO_Conf(void)
{
GPIO_InitTypeDef GPIO_InitStructure;

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3| GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_6 | GPIO_Pin_7;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOA, &GPIO_InitStructure);

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8;		   //zegar
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOA, &GPIO_InitStructure);	
RCC_MCOConfig(RCC_MCO_HSE);//wystawienie sygnalu zegarowego HSE dla kamerki 
 

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3|| GPIO_Pin_2;			//EN  oraz reset
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOB, &GPIO_InitStructure);

}








Thats all : ) bye !

I think it should be bit or (|) ??? :smiley:

bboyandru:
Hi, after a quick look at your code I have observed that you have to replace logically OR (||) with bitwise OR(|) in the configuration of PORT B.

cool_kuba:
I have wrote a test application to my samsung E700 camera and it doesn’t work ( i can si continuously the same sign) And Dave wrote that it should send images without any configuration. Maybe somebody has a idea what is wrong. OR someone can share code with me please. Here is my not really sophisticated code. I repeat it is only test.

PA0…7-Data

PA8 Clock output (8Mhz)

PB2 – Reset

PB3- Enable

Rest is not needed for my application.

Here it is:

#include "stm32f10x.h"

#include “lcd4bit.h”

void RCC_Conf(void);
void GPIO_Conf(void);
void NVIC_Conf(void);

void delay(int del)
{
int i, tmp;
tmp = 9000*del;
for(i=0;i<tmp;i++);
}

int main(void)
{
uint8_t Odczyt=0, setki, dziesiatki, jednosci,i;
#ifdef DEBUG
debug();
#endif
RCC_Conf();
NVIC_Conf();
GPIO_Conf();

LCD_Init();
LCD_Clear();
GPIO_SetBits(GPIOB,GPIO_Pin_3);//wlacz kamerke
GPIO_ResetBits(GPIOB,GPIO_Pin_2);  //reset
delay(100);
GPIO_SetBits(GPIOB,GPIO_Pin_2);	   
GPIO_SetBits(GPIOB,GPIO_Pin_3);//jeszcze raz wlacz jakby co
while (1)
{
for(i=0;i<4;i++	)
{
 if(GPIO_ReadInputDataBit(GPIOA, GPIO_Pin_7))	//odczyt bajtu danych (kurde jak inaczej)
	Odczyt |= 0x80;
if(GPIO_ReadInputDataBit(GPIOA, GPIO_Pin_6))
	Odczyt |= 0x40; 
if(GPIO_ReadInputDataBit(GPIOA, GPIO_Pin_5))
	Odczyt |= 0x20; 
if(GPIO_ReadInputDataBit(GPIOA, GPIO_Pin_4))
	Odczyt |= 0x10;  
if(GPIO_ReadInputDataBit(GPIOA, GPIO_Pin_3))	
	Odczyt |= 0x08;
if(GPIO_ReadInputDataBit(GPIOA, GPIO_Pin_2))
	Odczyt |= 0x04; 
if(GPIO_ReadInputDataBit(GPIOA, GPIO_Pin_1))
	Odczyt |= 0x02; 
if(GPIO_ReadInputDataBit(GPIOA, GPIO_Pin_0))
	Odczyt |= 0x01;  
 /*setki=(Odczyt/100)+48  ;
 Odczyt=Odczyt-setki*100;
 dziesiatki=(Odczyt/10)+48;
 Odczyt=Odczyt-dziesiatki*10;
 jednosci=Odczyt+48; 
 LCD_SendData(setki);
 LCD_SendData(dziesiatki);
 LCD_SendData(jednosci);	*/
 LCD_SendData(Odczyt);
 LCD_SendData(' ');
 delay(1000);
 Odczyt=0;
 }
  LCD_Clear();
}

}

void RCC_Conf(void)
{
ErrorStatus HSEStartUpStatus;
// Reset ustawien RCC
RCC_DeInit();
// Wlacz HSE
RCC_HSEConfig(RCC_HSE_ON);
// Czekaj za HSE bedzie gotowy
HSEStartUpStatus = RCC_WaitForHSEStartUp();
if(HSEStartUpStatus == SUCCESS)
{
FLASH_PrefetchBufferCmd(FLASH_PrefetchBuffer_Enable);
// zwloka dla pamieci Flash
FLASH_SetLatency(FLASH_Latency_2);
// HCLK = SYSCLK
RCC_HCLKConfig(RCC_SYSCLK_Div1);
// PCLK2 = HCLK
RCC_PCLK2Config(RCC_HCLK_Div1);
// PCLK1 = HCLK/2
RCC_PCLK1Config(RCC_HCLK_Div2);
// PLLCLK = 8MHz * 9 = 72 MHz
RCC_PLLConfig(RCC_PLLSource_HSE_Div1, RCC_PLLMul_9);
// Wlacz PLL
RCC_PLLCmd(ENABLE);
// Czekaj az PLL poprawnie sie uruchomi
while(RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET);
// PLL bedzie zrodlem sygnalu zegarowego
RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);
// Czekaj az PLL bedzie sygnalem zegarowym systemu
while(RCC_GetSYSCLKSource() != 0x08);
}
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE);
}

void GPIO_Conf(void)
{
GPIO_InitTypeDef GPIO_InitStructure;

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3| GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_6 | GPIO_Pin_7;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOA, &GPIO_InitStructure);

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8;		   //zegar
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOA, &GPIO_InitStructure);	
RCC_MCOConfig(RCC_MCO_HSE);//wystawienie sygnalu zegarowego HSE dla kamerki 
 

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3|| GPIO_Pin_2;			//EN  oraz reset
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOB, &GPIO_InitStructure);

}








Thats all : ) bye !