I am trying in vain to translate the MikroC example for Mikromedia 4 into MikroBasic (https://libstock.mikroe.com/projects/vi ... capacitive). It seems I have managed to translate most of the code, but the lines of code intended to pull up pins PD2, PC8 and PC9 fail, which, on the other hand, does not happen with the MikroC ... Am I doing something wrong or is there an error in the program descriptors?
Part written in C without problems:
Code: Select all
void Init_Ext_Mem() {
char FAT_cnt = 0;
char Fat_Init_Flag = 0;
rfStartSect = 0;
rfName = "Mikromed.RES";
// adjust this code to suite hw configuration
GPIO_Digital_Output(&GPIOD_BASE, _GPIO_PINMASK_2);
Mmc_Chip_Select = 1;
// Initialize SDIO
SDIO_Reset();
SDIO_Init(_SDIO_CFG_POWER_SAVE_DISABLE | _SDIO_CFG_4_WIDE_BUS_MODE | _SDIO_CFG_CLOCK_BYPASS_DISABLE
| _SDIO_CFG_CLOCK_RISING_EDGE | _SDIO_CFG_HW_FLOW_DISABLE, 125, &_GPIO_MODULE_SDIO_D0_D3);
// Set pull-ups on SDIO lines
GPIOD_PUPDRbits.PUPDR2 = 1;
GPIOC_PUPDRbits.PUPDR8 = 1;
GPIOC_PUPDRbits.PUPDR9 = 1;
GPIOC_PUPDRbits.PUPDR10 = 1;
GPIOC_PUPDRbits.PUPDR11 = 1;
Mmc_Set_Interface(_MMC_INTERFACE_SDIO);
if (Fat_Init_Flag == 0){
while ((FAT32_Init() != 0) && (FAT_cnt < 5))
FAT_cnt ++;
if (FAT_cnt < 5){
SDIO_Init(_SDIO_CFG_POWER_SAVE_DISABLE | _SDIO_CFG_4_WIDE_BUS_MODE | _SDIO_CFG_CLOCK_BYPASS_DISABLE
| _SDIO_CFG_CLOCK_RISING_EDGE | _SDIO_CFG_HW_FLOW_DISABLE, 1, &_GPIO_MODULE_SDIO_D0_D3);
Fat_Init_Flag = 1;
}
}
// Open resource file for read
rfHandle = FAT32_Open(rfName, 0x01);
rfStartSect = FAT32_ClustToSect(fat32_fdesc[rfHandle]._1stClust);
}
Code: Select all
sub procedure Init_Ext_Mem()
dim FAT_cnt as byte
dim Fat_Init_Flag as byte
FAT_cnt = 0
Fat_Init_Flag = 0
rfStartSect = 0
rfName = "Mikromed.RES"
Mmc_Chip_Select = 1
SDIO_Reset()
SDIO_Init(_SDIO_CFG_POWER_SAVE_DISABLE or _SDIO_CFG_4_WIDE_BUS_MODE or _SDIO_CFG_CLOCK_BYPASS_DISABLE
or _SDIO_CFG_CLOCK_RISING_EDGE or _SDIO_CFG_HW_FLOW_DISABLE, 125, @_GPIO_MODULE_SDIO_D0_D3)
'Set pull-ups on SDIO lines
GPIOD_PUPDR.PUPDR2 = 1 'ERROR!
GPIOC_PUPDR.PUPDR8 = 1 'ERROR!
GPIOC_PUPDR.PUPDR9 = 1 'ERROR!
GPIOC_PUPDR.PUPDR10 = 1 'OK!
GPIOC_PUPDR.PUPDR11 = 1 'OK!
Mmc_Set_Interface(_MMC_INTERFACE_SDIO)
if (Fat_Init_Flag = 0) then
while ((FAT32_Init() <> 0) and (FAT_cnt < 5))
inc(FAT_cnt)
if (FAT_cnt < 5) then
SDIO_Init(_SDIO_CFG_POWER_SAVE_DISABLE or _SDIO_CFG_4_WIDE_BUS_MODE or _SDIO_CFG_CLOCK_BYPASS_DISABLE
or _SDIO_CFG_CLOCK_RISING_EDGE or _SDIO_CFG_HW_FLOW_DISABLE, 1, @_GPIO_MODULE_SDIO_D0_D3)
Fat_Init_Flag = 1
end if
wend
end if
' Open resource file for read
rfHandle = FAT32_Open(@rfName, 0x01)
rfStartSect = FAT32_ClustToSect(fat32_fdesc[rfHandle]._1stClust)
end sub