Sunday, May 24, 2020

Executing with in Ram

After working out how to get the SDRAM working on the new hardware via the FMC (Stm32). Now testing and It APPEARS to be working.
Thats 8 Megabyte of RAM!.

Inside the 2 Meg ROM I have written something that will load a BIN file into the RAM and execute.
After that would perform a CPU jump!

The following section is called to jump to the program that is stored at memory location!

#define APPLICATION_ADDRESS 0xD0000000
typedef  void (*pFunction)(void);
pFunction JumpToApplication;
void Jump( void ) {
	GPIOD->BSRR = (1 << 11);// << 16;
	HAL_Delay(500);
	//CPU_CACHE_Disable();
	SysTick->CTRL = 0;
	//__disable_irq();
	JumpToApplication = (pFunction) (*(__IO uint32_t*) (APPLICATION_ADDRESS + 4));
	__set_MSP(*(__IO uint32_t*) APPLICATION_ADDRESS);
	SCB->VTOR = APPLICATION_ADDRESS;
	flogf("Address to Application: %lXrn", JumpToApplication);
	JumpToApplication();
}

—————
The LINKER file for the “bootloader” - our program that is in 2MB Rom -
IN the linker there is a memory section named MADDI, this is where the external ram is located, the FMC takes care of the bus and signals needed, basically this is a SDRAM memory controller - it allows for very large variables and arrays[s].

eg…
MADDI (xrw) : ORIGIN = 0xD0000000, LENGTH = 8M

/**
 ******************************************************************************
 * @file      LinkerScript.ld
 * @author    Auto-generated by STM32CubeIDE
 * @brief     Linker script for STM32F767IGTx Device from STM32F7 series
 *                      1024Kbytes FLASH
 *                      512Kbytes RAM
 *
 *            Set heap size, stack size and stack location according
 *            to application requirements.
 *
 *            Set memory bank area and size if external memory is used
 ******************************************************************************
 * @attention
 *
 * <h2><center>© Copyright (c) 2020 STMicroelectronics.
 * All rights reserved.</center></h2>
 *
 * This software component is licensed by ST under BSD 3-Clause license,
 * the "License"; You may not use this file except in compliance with the
 * License. You may obtain a copy of the License at:
 *                        opensource.org/licenses/BSD-3-Clause
 *
 ******************************************************************************
 */

/* Entry Point */
ENTRY(Reset_Handler)

/* Highest address of the user mode stack */
_estack = ORIGIN(RAM) + LENGTH(RAM);	/* end of "RAM" Ram type memory */

_Min_Heap_Size = 0x200 ;	/* required amount of heap  */
_Min_Stack_Size = 0x400 ;	/* required amount of stack */

/* Memories definition */
MEMORY
{
  RAM   (xrw) : ORIGIN = 0x20000000, LENGTH = 512K
  FLASH (rx)  : ORIGIN = 0x8000000,  LENGTH = 1024K
  MADDI (xrw) : ORIGIN = 0xD0000000, LENGTH = 8M
}

/* Sections */
SECTIONS
{
  /* The startup code into "FLASH" Rom type memory */
  .isr_vector :
  {
    . = ALIGN(4);
    KEEP(*(.isr_vector)) /* Startup code */
    . = ALIGN(4);
  } >FLASH

  /* The program code and other data into "FLASH" Rom type memory */
  .text :
  {
    . = ALIGN(4);
    *(.text)           /* .text sections (code) */
    *(.text*)          /* .text* sections (code) */
    *(.glue_7)         /* glue arm to thumb code */
    *(.glue_7t)        /* glue thumb to arm code */
    *(.eh_frame)

    KEEP (*(.init))
    KEEP (*(.fini))

    . = ALIGN(4);
    _etext = .;        /* define a global symbols at end of code */
  } >FLASH

  /* Constant data into "FLASH" Rom type memory */
  .rodata :
  {
    . = ALIGN(4);
    *(.rodata)         /* .rodata sections (constants, strings, etc.) */
    *(.rodata*)        /* .rodata* sections (constants, strings, etc.) */
    . = ALIGN(4);
  } >FLASH

  .ARM.extab   : { 
    . = ALIGN(4);
    *(.ARM.extab* .gnu.linkonce.armextab.*)
    . = ALIGN(4);
  } >FLASH
  
  .ARM : {
    . = ALIGN(4);
    __exidx_start = .;
    *(.ARM.exidx*)
    __exidx_end = .;
    . = ALIGN(4);
  } >FLASH

  .preinit_array     :
  {
    . = ALIGN(4);
    PROVIDE_HIDDEN (__preinit_array_start = .);
    KEEP (*(.preinit_array*))
    PROVIDE_HIDDEN (__preinit_array_end = .);
    . = ALIGN(4);
  } >FLASH
  
  .init_array :
  {
    . = ALIGN(4);
    PROVIDE_HIDDEN (__init_array_start = .);
    KEEP (*(SORT(.init_array.*)))
    KEEP (*(.init_array*))
    PROVIDE_HIDDEN (__init_array_end = .);
    . = ALIGN(4);
  } >FLASH
  
  .fini_array :
  {
    . = ALIGN(4);
    PROVIDE_HIDDEN (__fini_array_start = .);
    KEEP (*(SORT(.fini_array.*)))
    KEEP (*(.fini_array*))
    PROVIDE_HIDDEN (__fini_array_end = .);
    . = ALIGN(4);
  } >FLASH

  /* Used by the startup to initialize data */
  _sidata = LOADADDR(.data);

  /* Initialized data sections into "RAM" Ram type memory */
  .data : 
  {
    . = ALIGN(4);
    _sdata = .;        /* create a global symbol at data start */
    *(.data)           /* .data sections */
    *(.data*)          /* .data* sections */

    . = ALIGN(4);
    _edata = .;        /* define a global symbol at data end */
    
  } >RAM AT> FLASH

  /* Uninitialized data section into "RAM" Ram type memory */
  . = ALIGN(4);
  .bss :
  {
    /* This is used by the startup in order to initialize the .bss section */
    _sbss = .;         /* define a global symbol at bss start */
    __bss_start__ = _sbss;
    *(.bss)
    *(.bss*)
    *(COMMON)

    . = ALIGN(4);
    _ebss = .;         /* define a global symbol at bss end */
    __bss_end__ = _ebss;
  } >RAM

  /* User_heap_stack section, used to check that there is enough "RAM" Ram  type memory left */
  ._user_heap_stack :
  {
    . = ALIGN(8);
    PROVIDE ( end = . );
    PROVIDE ( _end = . );
    . = . + _Min_Heap_Size;
    . = . + _Min_Stack_Size;
    . = ALIGN(8);
  } >RAM
  
  	.extram :
    {
    	//. = ALIGN(8);
        *(.extram)           /* .data sections */
    	*(.extram*)          /* .data* sections */
    	KEEP (*(SORT(.extram.*)))
    	KEEP (*(.extram*))
    } >MADDI
  

  /* Remove information from the compiler libraries */
  /DISCARD/ :
  {
    libc.a ( * )
    libm.a ( * )
    libgcc.a ( * )
  }

  .ARM.attributes 0 : { *(.ARM.attributes) }
}

if you notice the “ROM” area is in 0xD0000000 THIS is where the FMC bus looks up the SDRAM-BANK1

/**
 ******************************************************************************
 * @file      LinkerScript.ld
 * @author    Auto-generated by STM32CubeIDE
 * @brief     Linker script for STM32F767IGTx Device from STM32F7 series
 *                      1024Kbytes FLASH
 *                      512Kbytes RAM
 *
 *            Set heap size, stack size and stack location according
 *            to application requirements.
 *
 *            Set memory bank area and size if external memory is used
 ******************************************************************************
 * @attention
 *
 * <h2><center>© Copyright (c) 2020 STMicroelectronics.
 * All rights reserved.</center></h2>
 *
 * This software component is licensed by ST under BSD 3-Clause license,
 * the "License"; You may not use this file except in compliance with the
 * License. You may obtain a copy of the License at:
 *                        opensource.org/licenses/BSD-3-Clause
 *
 ******************************************************************************
 */

/* Entry Point */
ENTRY(Reset_Handler)

/* Highest address of the user mode stack */
_estack = ORIGIN(RAM) + LENGTH(RAM);	/* end of "RAM" Ram type memory */

_Min_Heap_Size = 0x200 ;	/* required amount of heap  */
_Min_Stack_Size = 0x400 ;	/* required amount of stack */

/* Memories definition */
MEMORY
{
  RAM    (xrw)     : ORIGIN = 0xD0400000,   LENGTH = 2M
  FLASH    (rx)    : ORIGIN = 0xD0000000,    LENGTH = 2M
}

/* Sections */
SECTIONS
{
  /* The startup code into "FLASH" Rom type memory */
  .isr_vector :
  {
    . = ALIGN(4);
    KEEP(*(.isr_vector)) /* Startup code */
    . = ALIGN(4);
  } >FLASH

  /* The program code and other data into "FLASH" Rom type memory */
  .text :
  {
    . = ALIGN(4);
    *(.text)           /* .text sections (code) */
    *(.text*)          /* .text* sections (code) */
    *(.glue_7)         /* glue arm to thumb code */
    *(.glue_7t)        /* glue thumb to arm code */
    *(.eh_frame)

    KEEP (*(.init))
    KEEP (*(.fini))

    . = ALIGN(4);
    _etext = .;        /* define a global symbols at end of code */
  } >FLASH

  /* Constant data into "FLASH" Rom type memory */
  .rodata :
  {
    . = ALIGN(4);
    *(.rodata)         /* .rodata sections (constants, strings, etc.) */
    *(.rodata*)        /* .rodata* sections (constants, strings, etc.) */
    . = ALIGN(4);
  } >FLASH

  .ARM.extab   : { 
    . = ALIGN(4);
    *(.ARM.extab* .gnu.linkonce.armextab.*)
    . = ALIGN(4);
  } >FLASH
  
  .ARM : {
    . = ALIGN(4);
    __exidx_start = .;
    *(.ARM.exidx*)
    __exidx_end = .;
    . = ALIGN(4);
  } >FLASH

  .preinit_array     :
  {
    . = ALIGN(4);
    PROVIDE_HIDDEN (__preinit_array_start = .);
    KEEP (*(.preinit_array*))
    PROVIDE_HIDDEN (__preinit_array_end = .);
    . = ALIGN(4);
  } >FLASH
  
  .init_array :
  {
    . = ALIGN(4);
    PROVIDE_HIDDEN (__init_array_start = .);
    KEEP (*(SORT(.init_array.*)))
    KEEP (*(.init_array*))
    PROVIDE_HIDDEN (__init_array_end = .);
    . = ALIGN(4);
  } >FLASH
  
  .fini_array :
  {
    . = ALIGN(4);
    PROVIDE_HIDDEN (__fini_array_start = .);
    KEEP (*(SORT(.fini_array.*)))
    KEEP (*(.fini_array*))
    PROVIDE_HIDDEN (__fini_array_end = .);
    . = ALIGN(4);
  } >FLASH

  /* Used by the startup to initialize data */
  _sidata = LOADADDR(.data);

  /* Initialized data sections into "RAM" Ram type memory */
  .data : 
  {
    . = ALIGN(4);
    _sdata = .;        /* create a global symbol at data start */
    *(.data)           /* .data sections */
    *(.data*)          /* .data* sections */

    . = ALIGN(4);
    _edata = .;        /* define a global symbol at data end */
    
  } >RAM AT> FLASH

  /* Uninitialized data section into "RAM" Ram type memory */
  . = ALIGN(4);
  .bss :
  {
    /* This is used by the startup in order to initialize the .bss section */
    _sbss = .;         /* define a global symbol at bss start */
    __bss_start__ = _sbss;
    *(.bss)
    *(.bss*)
    *(COMMON)

    . = ALIGN(4);
    _ebss = .;         /* define a global symbol at bss end */
    __bss_end__ = _ebss;
  } >RAM

  /* User_heap_stack section, used to check that there is enough "RAM" Ram  type memory left */
  ._user_heap_stack :
  {
    . = ALIGN(8);
    PROVIDE ( end = . );
    PROVIDE ( _end = . );
    . = . + _Min_Heap_Size;
    . = . + _Min_Stack_Size;
    . = ALIGN(8);
  } >RAM

  /* Remove information from the compiler libraries */
  /DISCARD/ :
  {
    libc.a ( * )
    libm.a ( * )
    libgcc.a ( * )
  }

  .ARM.attributes 0 : { *(.ARM.attributes) }
}

with the Application it appears that you just create something as you would normally!

NOTE: compile to the BIN file, this wont work with .HEX or .ELF file!
the bin file contains OP codes

also this is said to run at about 5 times slow.. but have to rememeber, each step, the processor has to fetch a command, the fetch the data, then act upon the data, then store the result in one pipe.

where was program runs from the ROM and stores thigns in ram, this can be done with in just 2 cycles.

Sunday, May 17, 2020

A working DMA AUDIO output

sidboxv5begin.png The project begins to take life now; While its taken me a LONG time and most of my hair is still present!
I still have a long way to go, but I do have something that is causing us some excitement!

While working on the SDCARD (which now appears to be fully working now) I wanted to see if I could get the SDCARD to stream some audio.

At first I did this the old way as the Sidbox 4 does this, uses an interupt with a read and write audio buffer positions. While this works really well on the Sidbox 4 OS, this chip has 400Mhz and a few DMA channels, one of which is a DAC.

I can setup an audio buffer, and have that memory transferred at 441khz to the DAC, leaving the CPU free to do something else! The issue I got with this though is the DMA seems to collide a bit while using the FatFS (but thats just a current bug for now)

So the while it plays it just choses to put the new data in to the audio buffer

To Get this to work I had to wire up the following.

Note that this has NO Card Select! I was confused by this, but I found that I had to find away to tie the CS to 3.3v, the SDMMC1 port onthe STM32 takes care of everything else.

wiring-the-sdcard.jpg

So Now I have the SDCARD playing 8Bit Wav Files at 44100Hz and its done via the DMA,
all the CPU has to do when called via an interupt is to fetch another 1k of audio and stuff it in to the audio buffer.

Wednesday, May 13, 2020

SDCARD - Nucleoboard

nucleo.jpg The Nucleo-H743ZI2 - How much did I just bite off!!! Been at this problem for almost 2 weeks now, the SDCARD reader, VIA the SPI and SDMMC1 while they both worked with the example code, but those example code had other parts i didn’t need. So removing the parts that were’nt relevent to me my project, I ended up breaking the code.

IT was clearly required to create a whole new project - Now I’ve done this multiple times and each time the sodding FatFS didn’t work!

After I Found the debug infomation and actually a HUGE amount of info from a Facebook user by the name of Jeff, lent me his code for the sdcard, it wasn’t completed and didn’t work for what I needed, HOWEVER It did point me to the directions of the missing commands!

In the file

bsp_driver_sd.c
__weak uint8_t BSP_SD_Init(void)
{
  uint8_t sd_state = MSD_OK;
  /* Check if the SD card is plugged in the slot */
  //if (BSP_SD_IsDetected() != SD_PRESENT)
  //{
    //return MSD_ERROR_SD_NOT_PRESENT;
  //}
  /* HAL SD initialization */
  sd_state = HAL_SD_Init(&hsd1);

  return sd_state;
}

what I did was the comment the check to see if the card was inserted, while I will put this in later, i just wanted to know if the card worked.

The SDCard has 2.2K resistor pull-ups, connected to MOSI, and MISO - the MX IDE calls these, SDMMC1_CMD (mosi), SDMMC1_DO (miso).

on the Nucleoboard there are red, green and a yellow.

#define GREEN_PIN                                GPIO_PIN_0
#define GREEN_GPIO_PORT                          GPIOB

#define YELLOW_PIN                                GPIO_PIN_1
#define YELLOW_GPIO_PORT                          GPIOE

#define RED_PIN                                GPIO_PIN_14
#define RED_GPIO_PORT                          GPIOB

void PrepUserOI(){

	  __HAL_RCC_GPIOB_CLK_ENABLE();
	  __HAL_RCC_GPIOC_CLK_ENABLE();
	  __HAL_RCC_GPIOD_CLK_ENABLE();
	  __HAL_RCC_GPIOE_CLK_ENABLE();

	GPIO_InitTypeDef GPIO_InitStruct = {0};
	GPIO_InitStruct.Pin = GPIO_PIN_1;
	GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
	GPIO_InitStruct.Pull = GPIO_NOPULL;
	GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
	HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);

	GPIO_InitStruct.Pin = GPIO_PIN_0;
	GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
	GPIO_InitStruct.Pull = GPIO_NOPULL;
	GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
	HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);

	GPIO_InitStruct.Pin = GPIO_PIN_14;
	GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
	GPIO_InitStruct.Pull = GPIO_NOPULL;
	GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
	HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
}

inside the main file
the annoypart was to tell the system to START the sd_init();
sadly i couldn’t find this in the information documenations normally provided by ST.

here is how I got it working

 /* Initialize all configured peripherals */
  MX_GPIO_Init();
  MX_SDMMC1_SD_Init();
  MX_FATFS_Init();
  /* USER CODE BEGIN 2 */
  PrepUserOI();
  char res;
  res=0;
  //res = disk_initialize(0);
	res = BSP_SD_Init();
	if (res == FR_OK) {
		res = disk_initialize(0);
		if (res == FR_OK) {
			res = f_mount(&fs, "0:/", 0);
			if (res == FR_OK) {
				strcpy(buffer, "Hello world, this is a test");
				if (f_open(&fil, "hello world test file.txt", FA_CREATE_ALWAYS | FA_WRITE)
						== FR_OK) {

					f_write(&fil, buffer, sizeof(buffer), &bytes);
					f_close(&fil);

				}

			}
		}

	}

the code uploaded and begin to run, and instead of the yellow pulse range of around 200khz, i got the fill 12Mhz and some Blue pulses (this is the Data to the SDcard - MOSI)

sdcard_win1.png

with this I made a backup of this as the whole ordeal was awful!

BUT I concluded that while messy, the IDE and MX did do a good job of filling in the SDMMC1 and paring up to the SDCARD FatFS 0.12C

I have included the download of this project (its only for the Fat32 access)
CubeIDE GCC - C (not C++) Download Source

I’ll write up a more detailed what I found, how I figured out how to get this system to work!

Sunday, May 10, 2020

STM32H743ZI - Nucleo

nucleo.jpg While this bit of kit is nice looking, it has caused me alot of heart ache and frustration. It is MUCH different to that of the Microchips Eco System!

So if you are planning on moving away from Microchips to ST… BE Prepared to be spending alot of time getting to learn about the IDE and the example codes.

I Find my self stripping out code and learning how the chip works via the registers.

This Eco system by ST use something called HAL and it seems very bulky… However for right now I have no choice but to use the HAL_ stuff.

After pulling my hair out for days with the us of the SDCARD, and using MX to work out how to get things configured, I gave up.
I couldn’t find the research needed to help, and the manuals would take a long time. SO I did a cheat thing and found the demonstration code.

THIS allowed me to ensure that at least my wiring was correct and that it wasn’t the card that was broken or miss configured.

SO the demo code and the SDCAARD work

cleosd1.jpg The next issue I Faced was the problem of the card not really working well beyond the 2Gig. which would be a nightmware since out project needs to support up to about 32GIG, Fat32… Sadly the exFat comes with a hefty licence and just simply too expensive for us right now.

What this program does now is creats a text file, and spits “Hello world, this is a test file” then close the file
REMEMBER to close the file after you’ve done… some how it never gets commited to the card and looks like its doing nothing!

I am still having some seriously difficult times with this board due to its HAL and their eco system. The way the IDE copes with finding files and naming files I found to be an issue also.

The NEXT part I have to control now is making the UART to work, and that was tough enough as it was too.

WISH me luck.

BUT At least we got

  • Uart working (Debug and text output and input)
  • SDCard working (but not completely stable and signed off)
  • Able to use the GP I/O’s
  • I’ve already done the screen before so these screens work
  • DAC also works direct from this processor, so no external DAC is required.
  • STILL TO DO: External PSRAM access 133Mhz
  • Make Lots of money ;)

We’ll keep you posted as and when we get more features working on the new hardware.

The BOOT loader option might be a little tricky now since ST have no seperate rom for this, or at least i cant see how to make use of it yet, i need to get a demo of this working!

BUT that might come down later in the developement stage

Monday, May 4, 2020

And So, It begins!

sidboxv5begin.png AND so it begins, this is the info being returned from the new processor.

Took me all night, and I finally got it to do something!

The process of learning and being eager to get started and having some problems with the new IDE and methods for getting chips to turn on legs and not as fast as possible.

My Targets here is to get the following working…

  • Working: Serial port via a interupt.
  • Working: A Flashing light.
  • Working: BASIC: DAC with a basic Sawtooth output, i want to make this a DMA so I just dump audio into the DAC buffers.
  • TO DO: Display Driver.
  • TO DO: Buttons interfacing.
  • TO DO: SDCARD interfacing (this will be its own blog I believe. alot of work will be needed here I think.

sidbox5scope1.png

I hope to keep everyone updated here.

Sunday, May 3, 2020

STM32F767IG Begins!

ge64lqfp_stm32-40.jpg So it begins! New hardware, new programming, new struggles and NO HAIR.

I’ve been working on a board that has 2 items on it, 8MB Ram, and an STM32F767IG, while I have a long way to go I am learning alot in a few short days.

The IDE and the CubeMX is clunky and slow, but its a way into the evinronment. I am finding aspects of the chip confusing and hard to read manuals, I am from the envinronment of the Microchip controllers. Microchip have been good to me and while they offer some very good products and support, the fact that I would have to pay a subscription for using a GCC compiler if I wanted to have optimised for speed.

While looking for alternatives We came across this ST company doing some frightfully fast MCU’s. We found that MCUS for our project would be good. This allows for external ram and a whole host of peripherals.

I decided to make a log of the things I learn and figure out. Snippets of code and advise and things I found out along the way.
I am on day 2 of just working out how the Internal Clock is configured.. and using the MX it configures a lot, I would recommend saving your work if you use this as it likes to create the code for you and sometimes over writes the main().

// Testing the max speed of the GPIO pins
for (;;) {
		GPIOA->BSRR = (0xffff)<<16;	GPIOA->BSRR = (0xffff); 
		GPIOA->BSRR = (0xffff)<<16;	GPIOA->BSRR = (0xffff);
		GPIOA->BSRR = (0xffff)<<16;	GPIOA->BSRR = (0xffff);
		GPIOA->BSRR = (0xffff)<<16;	GPIOA->BSRR = (0xffff);
		GPIOA->BSRR = (0xffff)<<16;	GPIOA->BSRR = (0xffff);
		GPIOA->BSRR = (0xffff)<<16;	GPIOA->BSRR = (0xffff);
		GPIOA->BSRR = (0xffff)<<16;	GPIOA->BSRR = (0xffff);
		GPIOA->BSRR = (0xffff)<<16;	GPIOA->BSRR = (0xffff);
	}

the speed of this is QUICK at the CPU running (or should I say the clock settings) are set to 216Mhz. I’ve had to test.

it works, but I am still fuzzy on how things got setup and how they worked.

Right now. I am struggling with just getting a basic UART to work.

Programming the chip was a nightmare to setup until someone in the facebook group pointed out I needed to use or was better to use the CubeProgrammer, Which worked, using a TTL Serial to USB device I was able to use the OnBoard Serial Port BootLoader.

Got the first program working, which was the hello world blinky light.
Its not much but it at least is a start and away to help me believe I didn’t bite off more than I could chew!

I hope to progress.

resources to links i found:
https://gist.github. … 22a268ce890a118571ca

Friday, May 1, 2020

SoundTracker Pro II - Progress #3

soundtrack2.png Came a across a problem that prevented the tunes going from one pattern to the next.
Turns out that the format is capable of much more than just 64 rows in each pattern. As a result many crashes!

I figured just allowing more than 64, and made it available up to 128 rows in a pattern, some songs will have more, but if i did that more memory would be required and the system ram isn’t all that much at the moment (this will change in the new version of sidbox)

The problem with the timing came back too. I had a little trouble with the way the CIA timing was done. I did a lot of guess work because I couldn’t find the real value to start from.

With Maddi’s help I got a few songs from her and we tried all the tunes to get the right counters to work.

Thankfully there are only 15 possible positions the TEMPO can take and the fine tuning was easy to calculate after that.

Going to be fun finding out if the song can change its speed during playback.

Thank you for reading.

Wednesday, April 29, 2020

SoundTracker Pro II - Progress #2

soundtrack2.png As I continue to program, I bumped into a problem with the soundtracker pro 2. The problem was the Portamento function, while in Protracker, you keep repeating the command on each row until the note is finished portomentoeing (however you spell this! lol) .

To tackle the way SoundTracker Pro 2 deals with this, you set the note and its command ONCE, and the player assumes the command is in effect until a new note or command is used. I had to create a translator for this, since this would be too slow to keep doing while playing on the fly. On the pattern loading it deals with the commands for us. Set the command once, and the translator will add the same commands to the sequencial rows until the same rule occured.

As a result, we got a nice portamento effect working. I’ve still yet to completely test as each pattern is loaded, there is a good chance the translation system could reset and leave a note half portamento’d… only time and testing will tell…MsMadLemon is going to have a field day listening to her tunes and pointing out the things that didn’t work or does’t sound right.

so the progress report is done here :)

Thank you for reading.

Tuesday, April 28, 2020

SoundTracker Pro II - Progress - Effects

soundtrack2.png The project is now taking on some real meat now. The sounds and effects are seemingly working without even trying now. I am suprised and thankful that most of the commands in the format seem to work very very much the same as protracker! I’ve spent HOURS on that

49xx - Protracker sampleoffset command. Start sample at offset $xx00.
4E6x - Protracker patternloop command. x=0:set loop, x=n, loop n times
4EEx - Protracker patterndelay command. Delay x notes after playing note
4Fxx - Protracker speed/tempo command. xx<$20: set speed, xx>=$20: set bpm.

with these available to me i’ve been able to implement the Sampleoffset and the speed and temp commands now!

Monday, April 27, 2020

The History of the Sidbox

sidbox0.jpgThe day I began to play with the microcontrollers was fun and interesting, from just turning on motors to lighting up LED’s.

While these where fun and I did make some pretty cool devices, such as a home automation. I began to yern for things like audio.

In the end I learned what I could get my hands on, and one day while listening to good old Sid tunes with Sidplay.exe, I thought, I’d love to hear this stuff on a chip, instant ON battery powered SIDPlay.

I created my own audio Sidchip with 8 channels, but it was fairly basic, didnt’ have Ring mod, PWM controls… So I desperately looked into how the C64 played its chip tunes and I found it was a lot more involved than I initially thought… As a result I slumped and almost gave up, after about a year I decided to have another go.

Starting with the need for the 6502 Core, and I wrote a small program on it and found that the core did work, the CORE emulation worked on a PIC MCU running on a 40Mhz chip!

So I proceeded to learn about the SID 8582 (it was the only chip I physically had) and begin to learn how this bird sang.

After MONTHS of tearing hair our, punching walls and crying, I got a sidchip working, but it wasn’t enough, the SIDCHIP worked in my c64, but i wanted to have it independently PLAY music from the MCU it self, that required the CPU emulation also, which sadly the 40Mhz MCU worked well enough to produce a very very low quality sid noise

Upgrading from an 8BIT MCU i used the dsPIC24, 16bit running at 70Mhz which MADE alot of difference, and built this…

This little device did everything I needed, so I added a very basic file system FAT16 to it, and would only read ONE file on the root, but it loaded that sid tune into its small ram, 32K (so only a small sid file was allowed, 1k) and more programming time was thrown into this.

It picked up the file and BADLY played the SID tune, BUT it gave it a go.
After many more weeks of figuring out whats going on, was a stupid signed char, not a unsigned char that made the difference…
Gates worked, pitch and audio stepping and phase worked!

this chip could only produce a small 22khz output but it was more than good enough for tiny speakers.

I started to think this was IT, a portable SID player! instant on, ready to go in a second and playing music! (greating cards anyone?)

sidbox_start.jpgI wonder if I could make a 4 channel amiga MOD play on this, there wasn’t enough memory to perform this action here, so I upgraded to another dsPIC33 which had 512k Rom, and 128k Ram,

THEN this little machine was born

this was the very very first sidbox made, it had no volume control nor a DAC, it was purely done with an amp, the TDA2822 with a PWM source in, wow the pure clean sound (lol) it was grainy and alot of electrical noise appeared on this amp too! no filtering (since I was still researching how to do this)

I used this for a few days, before I began to really redesign the mainboard, this has a volume control and much better noise handling however the PCB still was a 2 layer board so all the signal and power rails where all mixed up on the 2 layers, yupp that was a rookie mistake right there…

sidbox3.jpg

still this unit and I got on with each other for just a year.

Then microchip sent me a sample chip, just turned up at the door and I thought, ok I’ll see what this does…

THAT was the PIC32MZ that we all know and love today!

pic32mz.jpg

it currently runs our sidbox now. I’ve been developing the OS and the players and a total redesign of the PCB, 4 layer board, with the two power plates inside the board, giving it a nice capacitor feel so everything got a nice gulp of power where it needed, and shielding. all the signals on the top and bottom layers for ram and display and virtually ZERO noise! there was some from the display but that was gone when I tethered a ground wire from the displays shield plate! now, there is no sound at all! Well not that I can tell. even with the Scopes!

sidbox4.jpg

This is what the sidbox is today.

We have begun a nice facebook group and is gaining interest everyday!

Soon we’ll be able to start the kickstarter!

With everyone backing and supporting this project, we’ll go far!!!

Sidbox 5 - Testing Board

It has come to our attention that the sidbox could do with a little more horse power, So what we have found was a new chip, the STM32H743

nucleo.jpg

It is 400Mhz (Can be 480 it appears!) of ARM CPU power! has 1 Meg of RAM ONBOARD!! and with 144 pin outs, This should allow for this like fast framerates, more animations on screen, and the ability to use external RAM transparently.

What we thought was to have this newer model come with 4 Meg of RAM, or 8 if we can find the same chip. I am still looking into what kind of RAM we can use, PSDRAM, DRAM or just good old (but expensive) SRAM.

So the new specs will be as follows!

  • 400 Mhz CPU
  • 1 Meg Internal Ram (for video and fast cache audio) with 4Meg External Ram
  • Internal DAC
  • DMA Screen data transfer (so the cpu can continue doing work while the screen is being updated!
  • Possible USB action, easy firmware update, it seems you just plug in the sidbox and it shows up like a drive letter, plop the new firmware on it and thats it!
  • More players, XM modules, and MORE S3M channels, i REALLY want to get TFMX to work

As We find out more about this chip and what it can do, We are sure to see some amazing things happening here

** This will not change the developement time because everything else is already done, unless we have to totally redesign the PCB and CASE which took me only a few weeks anyway **

I Really hope this new board will pose some serious applications!

Who knows! maybe a Sidbox Micro? Who wants to do some good BASIC on a Sidbox Micro? HANGS UP!!

Sunday, April 26, 2020

Put your thoughts here!

While I am working towards bettering the Blogging system, I am hoping to have good discussion base here.

Please keep it clean, no spam, no links to other websites (unless its related to the topic)

Thank you.

SoundTracker Pro II

soundtrack2.png After having a problem with reading the format provided by Marco Nelissen, I have to admit that the Psuedo code was a little hard for me to understand.

It wasn’t until ModPlug Tracker had they’re own loader written, C++, and when i looked into the file, things started to make sence.

As soon as I started to program my loader, the files .STP started to make sence, i’ve been since able to read the file as close to properly as possible.

As a result, I’ve been able to extract samples and their loop infomation, turns out i was able to extract each sample into a nice wav file for later use ;)

Then i found the patterns causing some issues. They could be any length from 1 - 9999! WHO USES THAT many rows in one pattern!! Anyways, I ended up having to use a sort of Pattern POINTER, its quick, and simple.

The messy part was, Load the Header, Look at the sample data, load the patterns and their info in to a bank of memory for the points, THEN re-read the sample data for their pointer locations.

I was then able to make patterns load and run. No effects, but the notes are almost identical to that of a Mod!
except i have to now work out the periods needed for the extra 2 octives!

here is the code i used to read through the file

void load_stp_header(FILE *file){
    unsigned char iOrder;
    fread(&mod, 1, 204, file);

    printf("HEADER: %srn", mod.ftype);
    btsEndien16(&mod.version); printf("VERS: %urn", mod.version);
    printf("patterns: %urn", mod.numOrders);
    printf("patternLength: %urn", mod.patternLength);

    btsEndien16(&mod.speed);      printf("speed: %urn", mod.speed);
    btsEndien16(&mod.speedFrac);  printf("speedFrac: %urn", mod.speedFrac);
    btsEndien16(&mod.numSamples); printf("numSamples: %urn", mod.numSamples);
    btsEndien16(&mod.timerCount); printf("timerCount: %u // %Xrn", mod.timerCount, mod.timerCount);
    btsEndien16(&mod.flags);      printf("flags: %urn", mod.flags);
    //btsEndien(&mod.reserved);   printf("reserved: %lurn", mod.reserved);

    printf("rnMidi Inforn");
    btsEndien16(&mod.midiCount);  printf("  MidiCount: %urn", mod.midiCount);
        //printf("    Midi[%2u] = [%2u]rn", iOrder, mod.midi[iOrder]);

    btsEndien16(&mod.sampleStructSize);  printf("rnsampleStructSize: %urn", mod.sampleStructSize);
    printf("-------------------------rnrn");

    Player.cia = mod.timerCount;
}

More to come…

About the Sidbox

Using the microchips MCU and an EXTERNAL SRAM 512k worth, it allows cache the tunes into that area, it allows to run 6502 from there also and the internal 512k SRAM is used for the video graphics, and ton of functions.

The unit has the power to unLHA good old archvies into ram, and then play them.

PLEASE NOTE: The unit is unavailable for sales at the moment, multple sections still not programmed and debugged.

The Sidbox

sidbox.jpg I’ve decided to try to do a blog on the progress of the Sidbox project.

you can find more out about this in the Sidbox Facebook Group

This is the sound of the sidbox as it stands right now

Songs list

  1. 1: Make Love (not war) Atari ST (With EQ on) (YM)
  2. 1: Make Love (not war) Atari ST (With EQ off) (YM)
  3. 2: Sanxion C64 SID (With EQ on) (SID)
  4. 2: Sanxion C64 SID (With EQ off) (SID)
  5. 3: Kefmania-Theme Amiga MOD (With EQ on) (MOD)
  6. 3: Kefmania-Theme Amiga MOD (With EQ off) (MOD)
  7. 4: Dispostable Hero CD32 WAV (With EQ on) (WAV)
  8. 4: Dispostable Hero CD32 WAV (With EQ off) (WAV)

have a good listen to!