본문 바로가기

[ST_MICRO]/STM32F4

STM32F4 - VS1053 MP3 Module Test

 STM32F4 - VS1053 MP3 Module Test

 

 

 

STM32F4 를 이용하여 MP3출력시 소비 전류 측정을 위해 [LCD-EXP EVM] 보드를 이용하여 테스트 했다.

 

SPI클럭을 1.2mhz로 구동하고 클럭 분주를 1/2 로 설정하니 전류가 80mA -> 65mA로 줄어 들었다.


클럭을 좀더 낮추니 (1/4) 60mA로 줄어 든다. 이 상태에서도 MP3출력은 잘된다.
이때 SPI클럭을 좀더 올려 줬다.
SPI1_InitStructure.SPI_BaudRatePrescaler=SPI_BaudRatePrescaler_8;

static void SetSysClock(void)
{
 :

    /* HCLK = SYSCLK / 1*/
//    RCC->CFGR |= RCC_CFGR_HPRE_DIV1;
    RCC->CFGR |= RCC_CFGR_HPRE_DIV4; 

:

}

 


사용하지 않는 페리 끌수 있으면 좀더 줄지 않을까...

저전력 MCU가 아니라서 옵션이 많지 않은것이 아쉽다.

 

[LCD-EXP EVM] 회로도


 

 

[STM32F4 EVM] VS1053 제어 드라이버 코드

 

//-----------------------------------------------------------------------------
// SD Card HAL
#define _DEBUG_FAT_FILE                 0


#define MMC_CS_PORT      GPIOA
#define MMC_CS_BIT      BIT7

#define MMC_CS_INIT()     RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);\
          GPIO_InitStructure.GPIO_Pin = MMC_CS_BIT|BIT4|BIT5;\
          GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;\
          GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;\
          GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;\
          GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;\
          GPIO_Init(GPIOA, &GPIO_InitStructure);Sbi(PORTA, BIT4|BIT5)
         
#define MMC_CS_HIGH()     sbi(MMC_CS_PORT, MMC_CS_BIT)
#define MMC_CS_LOW()     cbi(MMC_CS_PORT, MMC_CS_BIT)
#define MMC_ASSERT_INIT()    MMC_CS_INIT();MMC_CS_HIGH()
#define MMC_ASSERT()     MMC_CS_LOW()
#define MMC_DEASSERT()     MMC_CS_HIGH()


#define MMC_SpiInit()     SPI1_Init()
#define MMC_SendByte     SPI1_WriteReadByte
#define MMC_Send(Data)      SPI1_WriteByte(Data)
#define MMC_Recv()      SPI1_WriteReadByte(0xFF)
#define MMC_RecvP(Data)     MMC_Send(0xFF); (*(Data)=SPI1_ReadByte())
#define MMC_SPISpeed     SPI1_SetSpeed

#define SPI_Mode3()

#define FAT_MAX_NUM_FILE          50

#define FCLK_SLOW()             MMC_SPISpeed(SPI_SPEED_1MHZ) 
#define FCLK_FAST()             MMC_SPISpeed(SPI_SPEED_MAX)
//-----------------------------------------------------------------------------

 


//-----------------------------------------------------------------------------
// VS1053 Drvier
//-----------------------------------------------------------------------------
#define VS_DREQ_BIT          BIT6
#define VS_DREQ_PORT         PORTA

#define VS_CS_BIT          BIT5
#define VS_CS_PORT          PORTA


#define VS_RST_BIT      
#define VS_RST_DDR      
#define VS_RST_PORT      


#define VS1003_DREQ()           ((GPIOA->IDR&VS_DREQ_BIT))


#define VS1003_CS_H()      Sbi(VS_CS_PORT, VS_CS_BIT)
#define VS1003_CS_L()      Cbi(VS_CS_PORT, VS_CS_BIT)

#define vs1003_enable()      VS1003_CS_L()
#define vs1003_disable()     VS1003_CS_H()

#define VS_XDCS_BIT          BIT4
#define VS_XDCS_PORT         GPIOA
#define VS1003_XDCS_H()      sbi(VS_XDCS_PORT, VS_XDCS_BIT)
#define VS1003_XDCS_L()      cbi(VS_XDCS_PORT, VS_XDCS_BIT)


#define VS1003_RESET_H()     //Sbi(VS_RST_PORT, VS_RST_BIT)
#define VS1003_RESET_L()     //Cbi(VS_RST_PORT, VS_RST_BIT)

#define IsVs1003DataReady()     (GPIOA->IDR&VS_DREQ_BIT)

#define VS_SendByte       SPI1_WriteReadByte
#define VS_InitSpi()      //SPI1_Init()
#define VS_SpiSpeed_Low()        SPI1_SetSpeed(SPI_SPEED_1MHZ)
#define VS_SpiSpeed_High()     SPI1_SetSpeed(SPI_SPEED_4MHZ)


#define MP3_PORT_INIT()         RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);\
              GPIO_InitStructure.GPIO_Pin = BIT4|BIT5;\
              GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;\
              GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;\
              GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;\
              GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;\
              GPIO_Init(GPIOA, &GPIO_InitStructure);\
              GPIO_InitStructure.GPIO_Pin = VS_DREQ_BIT;\
                                            GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;\
              GPIO_Init(GPIOA, &GPIO_InitStructure);\
                                            VS1003_CS_H();VS1003_XDCS_H()
//-----------------------------------------------------------------------------

반응형