Olimex STM32-H103 + ARM-JTAG + IAR AW-ARM 5.2 need help

Hi everyone,

I’m newbie in ARM(have experience only with PICs). So I have

  1. Windows XP Pro

  2. Development board from Olimex STM32-H103(http://www.olimex.com/dev/stm32-h103.html)

  3. Olimex ARM-Jtag (http://www.olimex.com/dev/arm-jtag.html)

  4. IAR EW-ARM 5.2

What I want:

  • Just turn on, turn off STAT Led on the board (connected to PC12)

Also I installed H-JTAG 0.9.1, download firmware from official ST web site and just modify template project.

main.c

#include "stm32f10x_lib.h"
/* Private variables ---------------------------------------------------------*/
GPIO_InitTypeDef GPIO_InitStructure;
ErrorStatus HSEStartUpStatus;
volatile unsigned long _1ms_counter;
/* Private function prototypes -----------------------------------------------*/
void RCC_Configuration(void);
void NVIC_Configuration(void);
void port_init(void);
void sys_tick_init(void);
void delay_ms(unsigned long delay);

int main(void){
    RCC_Configuration(); // System Clocks Configuration
    NVIC_Configuration();
    port_init();
    //sys_tick_init();
    
    while(1){
      GPIO_SetBits(GPIOC, GPIO_Pin_12);
      delay_ms(500000);
      GPIO_ResetBits(GPIOC, GPIO_Pin_12);
      delay_ms(500000);
    }
}

void RCC_Configuration(void)
{
  /* RCC system reset(for debug purpose) */
  RCC_DeInit();
  /* Enable HSE */
  RCC_HSEConfig(RCC_HSE_ON);
  /* Wait till HSE is ready */
  HSEStartUpStatus = RCC_WaitForHSEStartUp();
  if(HSEStartUpStatus == SUCCESS)
  {
    /* Enable Prefetch Buffer */
    FLASH_PrefetchBufferCmd(FLASH_PrefetchBuffer_Enable);
    /* Flash 2 wait state */
    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);
    /* Enable PLL */
    RCC_PLLCmd(ENABLE);
    /* Wait till PLL is ready */
    while(RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET)
    {
    }
    /* Select PLL as system clock source */
    RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);
    /* Wait till PLL is used as system clock source */
    while(RCC_GetSYSCLKSource() != 0x08)
    {
    }
  }
}

void NVIC_Configuration(void){
    NVIC_InitTypeDef NVIC_InitStructure;
#ifdef  VECT_TAB_RAM
    /* Set the Vector Table base location at 0x20000000 */
    NVIC_SetVectorTable(NVIC_VectTab_RAM, 0x0);
#else  /* VECT_TAB_FLASH  */
    /* Set the Vector Table base location at 0x08000000 */
    NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x0);
#endif
}
//------------------------------------------------------------------------------
void port_init(void){
   RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE);
   RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOA, ENABLE);
   // Configure PC.12 as output push-pull (LED)
   GPIO_WriteBit(GPIOC,GPIO_Pin_12,Bit_SET);
   GPIO_InitStructure.GPIO_Pin =  GPIO_Pin_12;
   GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
   GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
   GPIO_Init(GPIOC, &GPIO_InitStructure);

}
//------------------------------------------------------------------------------
void sys_tick_init(void){
    SysTick_SetReload(9000);
    SysTick_ITConfig(ENABLE);
    SysTick_CounterCmd(SysTick_Counter_Enable);
}
//------------------------------------------------------------------------------
void delay_ms(unsigned long delay){
    unsigned long temp = _1ms_counter;
    while( _1ms_counter-temp < delay );
}

+STM firmware library

So, I compile & build project in IAR without errors, connect ARM-Jtag to PC, connect USB to dev board(for power supply), attach Jtag to dev board, startup H-Jtag server(target found Cortex M3), then press Ctrl-D in IAR (Download & Debug), press Go. And nothing…

Also I generate .Hex & program board via H-Flasher. Programing & verification without error, but Led on board doesn’t blink. :?:

Can anyone help me?

My project in IAR http://rapidshare.com/files/212671925/b … d.rar.html

It looks the problem is your delay function. Try this:

void Delay(vu32 nCount)
{
  for(; nCount != 0; nCount--);
}

OR use this main to keep your led on(without blinking)

int main(void){
    RCC_Configuration(); // System Clocks Configuration
    NVIC_Configuration();
    port_init();

    GPIO_ResetBits(GPIOC, GPIO_Pin_12);
    while(1){    }
}

nibj, thanks a lot!!! It’s works!!! :smiley:

OK, my development board & toolchain works fine, but I have problem with USB examples from ST (http://www.st.com/stonline/products/sup … um0424.zip).

I have tested “Virtual Com Port” & “Mass Storage Device” examples, all of them compiled & proggrammed without errors. But when device connected to PC nothing happens :frowning: No sound or icons from Windows, that “removable”\storage device connected. Just status LED on the board is on. USB on PC works fine. In case of VCP all drivers was installed properly. Device was tested on WinXP & Vista…

There is USBP-E jumber on the board, maybe it’s a problem? Any suggestions?

Check the defines, USB_DISCONNECT, USB_DISCONNECT_PIN and RCC_APB2Periph_GPIO_DISCONNECT on the file plataform_config.h

For the olimex boards, the pin is C.11

Problem solved!

I used example for STM3210B-EVAL evaluation board, but Olimex STM32-H103 have different scheme, so I just changed hardware config in platform_config.h

From:

   #define USB_DISCONNECT            GPIOD  
  #define USB_DISCONNECT_PIN        GPIO_Pin_9
  #define RCC_APB2Periph_GPIO_DISCONNECT      RCC_APB2Periph_GPIOD

To:

  #define USB_DISCONNECT            GPIOC  
  #define USB_DISCONNECT_PIN        GPIO_Pin_11
  #define RCC_APB2Periph_GPIO_DISCONNECT      RCC_APB2Periph_GPIOC

:wink:

So next step. I want to control my device (based on STM32-H103) by PC via USB. I think Virtual Com Port is simplest way.

Any suggestions\exmaples?

Yes, the VirtualCom is probably the simplest way. Check [this topic on the ST support forum.

USB HID is a good option too, check both ECG projects(firmware and application) on the http://www.stm32circle.com/](http://www.st.com/mcu/forums-cat-6663-23.html)

Ok, nibj, thx for reply.

I’ll check that topics.

I have get “Hello, World!” from my device after modification of ST “Virtual Com Port” example. I just turn off USART, add led blinking lines to recieve function(USB_To_USART_Send_Data()) and send “hello, world!” string when push the user button (via USART_To_USB_Send_Data()).

But some times data loss occuries. When I push the button, I get “Hello Hello” or something like this instead of proper string. What can be wrong :?:

I check nibj’s links. Topic on ST forum is very interesting(stdio via USB), but I can’t complie it under IAR

I need your help, again…