Register

Sending Audio Data To The Serial Port?

Discuss issues related to the fx-9860G Software Development Kit
Junior Member
Posts: 4
Joined: Wed Mar 19, 2014 10:23 pm
Calculators: Casio fx-9750GII (SH4), Casio fx-9860GII, Casio Classpad 330 plus, Casio fx-CG50, Casio Classpad fx-CP400

Sending Audio Data To The Serial Port?

Postby shinolife63 » Wed Mar 19, 2014 10:35 pm

Hello, first off I feel I should state that I own a Casio fx-9750GII hacked to run the 9860 SH4 OS

Ive been attempting to get a basic audio player working for a while now (All I want to do is generate morse code), the closest Ive come is attempting to compile this:
http://community.casiocalc.org/topic/6428-fx-9860gii-music-player (Which states that it works for hacked 9750's, and has a video proving it)
I set everything up correctly, but when I go to compile, it throws errors like crazy, the author stated that he had uploaded a revised version that he didn't actually have time to test out, which explains all the errors... :(

Unfortunately, ive been unable to find any source code that would even give me a clue of how to accomplish this myself, and I cant find any documentation either...

If anyone has some example code or addins that would help me accomplish this, It would be greatly appreciated :)

Senior Member
Posts: 369
Joined: Tue Jan 03, 2012 11:24 pm
Calculators: Casio Afx 1.0, Casio fx-9860GII SD, Casio Classpad 330, Casio fx-CG20, Casio Classpad fx-CP400

Re: Sending Audio Data To The Serial Port?

Postby helder7 » Wed Mar 19, 2014 10:51 pm

There is a topic here in the forum with an adaptation of MPoupe audio player for SH4 calculators: viewtopic.php?f=11&t=1440

See if it helps.
SiO2 + CaCO3 ----------> CaSiO3 + CO2

Junior Member
Posts: 4
Joined: Wed Mar 19, 2014 10:23 pm
Calculators: Casio fx-9750GII (SH4), Casio fx-9860GII, Casio Classpad 330 plus, Casio fx-CG50, Casio Classpad fx-CP400

Re: Sending Audio Data To The Serial Port?

Postby shinolife63 » Thu Mar 20, 2014 4:21 am

helder7 wrote:There is a topic here in the forum with an adaptation of MPoupe audio player for SH4 calculators: http://casiopeia.net/forum/viewtopic.php?f=11&t=1440

See if it helps.

Yeah, ive seen that thread, the code posted there is actually incredibly helpful, except I have no idea where to find the 7305.h header file, and the download link that went along with the code is broken :(
Do you know where I could get either a working version of that dL link or the 7305.h header???
Thanks ^^

Senior Member
Posts: 369
Joined: Tue Jan 03, 2012 11:24 pm
Calculators: Casio Afx 1.0, Casio fx-9860GII SD, Casio Classpad 330, Casio fx-CG20, Casio Classpad fx-CP400

Re: Sending Audio Data To The Serial Port?

Postby helder7 » Thu Mar 20, 2014 2:30 pm

I found the 7305.h file here: http://www.omnimaga.org/casio-prizm/aud ... tach=11926

I do not have the compiled file, but with 7305.h and the source code, you should be able to compile it.
SiO2 + CaCO3 ----------> CaSiO3 + CO2

Junior Member
Posts: 4
Joined: Wed Mar 19, 2014 10:23 pm
Calculators: Casio fx-9750GII (SH4), Casio fx-9860GII, Casio Classpad 330 plus, Casio fx-CG50, Casio Classpad fx-CP400

Re: Sending Audio Data To The Serial Port?

Postby shinolife63 » Fri Mar 21, 2014 9:27 pm

helder7 wrote:I found the 7305.h file here: http://www.omnimaga.org/casio-prizm/aud ... tach=11926

I do not have the compiled file, but with 7305.h and the source code, you should be able to compile it.

Ugh, its still not compiling correctly, I have the 7305 Header file in the same folder as my project, like normal, and I have my 8-bitunsigned "TEST.wav" file in the directory as is instructed, but when I go to compile, I get the following error:
Code: Select all
Executing Hitachi SH C/C++ Compiler/Assembler phase

set SHC_INC=C:\Program Files\CASIO\fx-9860G SDK\OS\SH\include
set PATH=C:\Program Files\CASIO\fx-9860G SDK\OS\SH\bin
set SHC_LIB=C:\Program Files\CASIO\fx-9860G SDK\OS\SH\bin
set SHC_TMP=C:\Users\Aspire 1\Desktop\Music\Music\Debug

Executing Hitachi OptLinker04 phase

"C:\Program Files\CASIO\fx-9860G SDK\OS\SH\bin\Optlnk.exe" -subcommand=C:\Users\ASPIRE~1\AppData\Local\Temp\hmkCDCB.tmp

** L2310 (E) Undefined external symbol "_Serial_Close" referenced in "C:\Users\Aspire 1\Desktop\Music\Music\Debug\Music.obj"

Optimizing Linkage Editor Abort

HMAKE MAKE UTILITY Ver. 1.1
Copyright (C) Hitachi Micro Systems Europe Ltd. 1998
Copyright (C) Hitachi Ltd. 1998


   ERROR: Process failed with return code: 1
Build was not successful.


The code I am attempting to compile is Casimo's on http://casiopeia.net/forum/viewtopic.php?f=11&t=1440:
Code: Select all
#include "fxlib.h"
#include "7305.h"

#define DATAPACK 8080

unsigned char UserStack[DATAPACK];

//Conversion tables
#define X 0x10
#define _ 0x00

static const unsigned char LowTable[16]=
{
   _,_,_,_,//0
   X,_,_,_,//1
   X,_,X,_,//2
   _,X,X,X,//3
};

                               //0    1    2    3    4    5    6    7
static const unsigned char HighTable[8]={0x00,0x01,0x44,0x45,0x65,0x67,0xE7,0xEF};

#define gpBuffer UserStack

//static unsigned char *gpBuffer;
static unsigned int giBufIndex = 0;
static unsigned char giTableIndex = 0;
static unsigned char giSubSample = 0;
static unsigned char giFromHighTab = 0;

static int ComOpen()
{
   //unsigned char settings[5]={0,9,0,1,0};//115200,2xstop bits
   unsigned char settings[5]={0,9,0,0,0};//115200,1xstop bits
   if(Serial_Open(&settings))
   {
      return 1;
   }
      //SCIF2.SCSMR.BIT.SRC = 1;//1/5 (for 9860)

   //it has no SRC register (comparing to fx9860G), so actual speed is only ~ 460800
   //SCIF2.SCSMR.BIT.SRC = 0;//1/16 (for 9860)
   SCIF2.SCSMR.BIT.CKS = 0;//1/1
      //SCIF2.SCBRR = 2;//!override speed to 1959390 bps (for 9860)
   SCIF2.SCBRR = 0;//!override speed to 1836000 bps (for 9860)
   return  0;
}

int AddIn_main(int isAppli, unsigned short OptionNum)
{
   FONTCHARACTER path[] ={'\\','\\','f','l','s','0','\\','T','E','S','T','.','w','a','v',0};
   unsigned int i, size;
   unsigned int code1, code2;
   int hFile = Bfile_OpenFile(path, _OPENMODE_READ);
   //skip wav header
   if(Bfile_ReadFile(hFile,UserStack,44,-1) != 44)
   {
      return 0;
   }

   size = Bfile_GetFileSize(hFile);
   ComOpen();
   Bdisp_AllClr_VRAM();
   locate( 1, 1 );
   Print(&"Playing");
   Bdisp_PutDisp_DD();

   //read it
   for(i = 0; i < size; i+= DATAPACK)
   {
      Bfile_ReadFile(hFile,UserStack ,DATAPACK,-1);
      for(giBufIndex = 0; giBufIndex < DATAPACK;)
      {
         //it has only 16 B fifo :-(
         while ((SCIF2.SCFDR.WORD >> 8) < 16)
         {
            if(giTableIndex >= 4)
            {
               giSubSample = gpBuffer[giBufIndex++] >> 3;
               giFromHighTab = HighTable[giSubSample>>2];
               giSubSample = (giSubSample & 3) << 2;
               giTableIndex = 0;
            }
            SCIF2.SCFTDR = (unsigned char)LowTable[giSubSample|giTableIndex]|giFromHighTab;
            giTableIndex++;
         }
      }
      if(Bkey_GetKeyWait(&code1,&code2,KEYWAIT_HALTOFF_TIMEROFF,0,1,0) == KEYREP_KEYEVENT)
      {
         if(code1 == 4 && code2 == 8)
         break;
      }
   }
   Bfile_CloseFile(hFile);
   Serial_Close(1);
}

#pragma section _BR_Size
unsigned long BR_Size;
#pragma section
#pragma section _TOP
int InitializeSystem(int isAppli, unsigned short OptionNum)
{return INIT_ADDIN_APPLICATION(isAppli, OptionNum);}
#pragma section


Any ideas? :|

Senior Member
Posts: 369
Joined: Tue Jan 03, 2012 11:24 pm
Calculators: Casio Afx 1.0, Casio fx-9860GII SD, Casio Classpad 330, Casio fx-CG20, Casio Classpad fx-CP400

Re: Sending Audio Data To The Serial Port?

Postby helder7 » Mon Mar 24, 2014 12:28 am

You need to define the syscalls for serial communication, with a syscalls.src file: viewtopic.php?f=11&t=1557#p13320
SiO2 + CaCO3 ----------> CaSiO3 + CO2

Junior Member
Posts: 4
Joined: Wed Mar 19, 2014 10:23 pm
Calculators: Casio fx-9750GII (SH4), Casio fx-9860GII, Casio Classpad 330 plus, Casio fx-CG50, Casio Classpad fx-CP400

Re: Sending Audio Data To The Serial Port?

Postby shinolife63 » Mon Mar 24, 2014 9:17 pm

helder7 wrote:You need to define the syscalls for serial communication, with a syscalls.src file: viewtopic.php?f=11&t=1557#p13320

Wonderful! My code "works", it doesn't throw any errors related to syntax or me screwing up in general, but now it throws:

Code: Select all
HMAKE MAKE UTILITY Ver. 1.1
Copyright (C) Hitachi Micro Systems Europe Ltd. 1998
Copyright (C) Hitachi Ltd. 1998


   Make proccess completed

The size of B and R section should be 0x2000 bytes or less.
Please refer to "C:\Users\Aspire 1\Desktop\Music\Music\Debug\FXADDINror.map".

Build was not successful.

From what ive gathered from: http://www.casiokingdom.org/calculator-forum/index.php?topic=527.0 and http://community.casiocalc.org/topic/3724-clearingupdating-buffers/, I need to optimize my code, but Im not sure what data types are interchangeable without breaking the whole program, anywhere you might be able to point me to for that? :D

Senior Member
User avatar
Posts: 605
Joined: Sat Sep 15, 2012 6:59 am
Location: Krautland ****
Calculators: Casio fx-7400GII, Casio fx-7400GII (SH4), Casio fx-9750GII, Casio fx-9750GII (SH4), Casio fx-9860G, Casio fx-9860G SD, Casio fx-9860G Slim, Casio fx-9860GII SD, Casio fx-9860GII SD Power Graphic 2, Casio Classpad 330 plus, Casio fx-CG20, Casio fx-CG50, Casio Classpad fx-CP400

Re: Sending Audio Data To The Serial Port?

Postby SimonLothar » Tue Mar 25, 2014 1:30 pm

Reduce the use of global variables, t. i. variables, which are declared outside of any function and without "const" or with "static".
Inspect the map-file to find variables, which are stored in B- or R-segment.
I'll be back!

Return to Casio fx-9860 SDK

Who is online

Users browsing this forum: No registered users and 18 guests