Mikroelektronika MIKROE-724 データシート

ページ / 726
mikroBasic PRO for dsPIC30/33 and PIC24
MikroElektronika
407
‘--- set up USART for the file read
    SPI1_Init_Advanced(_SPI_MASTER,  _SPI_8_BIT,  _SPI_PRESCALE_SEC_1,  _SPI_PRESCALE_
PRI_64,
                    _SPI_SS_DISABLE, _SPI_DATA_SAMPLE_MIDDLE, _SPI_CLK_IDLE_HIGH, _SPI_
ACTIVE_2_IDLE)
  UART1_Init(19200)                      ‘ Initialize UART module at 9600 bps
  Delay_ms(100)                          ‘ Wait for UART module to stabilize
  U1MODE.ALTIO = 1  ‘ Switch Rx and Tx pins on their alternate locations.
                    ‘ This is used to free the pins for other module, namely the SPI.
                                           
  UART_Write_Line(“dsPIC-Started”)       ‘ dsPIC present report
  ‘ use fat16 quick format instead of init routine if a formatting is needed
  if Mmc_Fat_Init() = 0 then
    ‘ reinitialize spi at higher speed
    SPI1_Init_Advanced(_SPI_MASTER, _SPI_8_BIT, _SPI_PRESCALE_SEC_1, _SPI_PRESCALE_PRI_4,
    _SPI_SS_DISABLE, _SPI_DATA_SAMPLE_MIDDLE, _SPI_CLK_IDLE_HIGH, _SPI_ACTIVE_2_IDLE)
    ‘--- Test start
    UART_Write_Line(“Test Start.”)
    M_Create_New_File()
    #IFDEF COMPLETE_EXAMPLE
    M_Create_Multiple_Files()
    M_Open_File_Rewrite()
    M_Open_File_Append()
    M_Open_File_Read()
    M_Delete_File()
    M_Test_File_Exist()
    M_Create_Swap_File()
    #ENDIF
    UART_Write_Line(“Test End.”)
  else
    UART_Write_Line(err_txt) ‘ Note: Cf_Fat_Init tries to initialize a card more than once.
      ‘       If card is not present, initialization may last longer (depending on clock speed)
  end if
end.
HW Connection
Pin diagram of MMC memory card