Phatline Posted December 10, 2014 Report Share Posted December 10, 2014 (edited) any tips, from which program i can crap the code? the blm code: http://ucapps.de/mios/blm_scalar_v1_0a.zip the LEDs on the Matrix-Board connectetd to J3_1 going to Scalar-Board looking very simular to the SID-Matrix Shematic, except the Transistors, and without the 8 Resistors. & this code is what i see a 8Bit app... so the way to go, i think? A other Idea, get it from the ASM - codet - SID Application SID ASM code: http://ucapps.de/mios/midibox_sid_v2_043.zip because the documentation of "MIOS8 C Interface" says: Keep in mind that mixing C and assembler at application layer is still possible and under the folder src is a file named: "cs_menu_matrix.inc"" >>> but how to mix that? - where to copy this file, how to load it in the main.c, which command to add and so on. the button thing is clear, but the LED thing where to send my 00 01 02 03 04 05 06 07, 10 11 12 13... not so clear, because of multiplexing... ok in one second that pin and that pin, in the other ms that pin and that pin, but in real code ---pfffuuu to much (newbee) --- but i think that is handled in background, without a need to know (like normal din, out, that in main.c give me notifcation if something happens, or in main c activate a dout pin...) i have more time up tomorrow to get into this, but a quickstart, or a startpoint is really welcome! thankz Edited December 10, 2014 by Phatline Quote Link to comment Share on other sites More sharing options...
TK. Posted December 10, 2014 Report Share Posted December 10, 2014 Today you replied to a posting which gives you a link to a C based application which is a much better example: Best Regards, Thorsten. Quote Link to comment Share on other sites More sharing options...
bill Posted December 12, 2014 Report Share Posted December 12, 2014 Btw, you could be interested in this : http://www.dx.com/p/8-x8-dot-matrix-driver-module-red-black-196521 Quote Link to comment Share on other sites More sharing options...
Phatline Posted December 12, 2014 Author Report Share Posted December 12, 2014 thankz for the tip, but no - not intrested, my matrix is already wired Quote Link to comment Share on other sites More sharing options...
Phatline Posted December 12, 2014 Author Report Share Posted December 12, 2014 (edited) What I found: http://svnmios.midib...s/midibox_mm/ (see SR_Service_Prepare() function in src/main.c and the appr. code in src/mm_vpot.c) The actual DOUT transfers are handled by MIOS8 in background with an optimized assembly based routine. Mechanism: SR_Service_Prepare() will be called before the SRIO scan (each mS) In this function, increment a counter variable on each cycle, reset to 0 once it reaches 16 Transfer the new pattern (which corresponds to the counter and is ideally stored in an array) via MIOS_DOUT_SRSet MIOS_DOUT_SRSet C_DECLARATION: void MIOS_DOUT_SRSet(unsigned char sr, unsigned char sr_value) DESCRIPTION: sets value of DOUT shift register C_IN: number of shift register in <sr> value in <sr_value> Edited December 12, 2014 by Phatline Quote Link to comment Share on other sites More sharing options...
Phatline Posted December 12, 2014 Author Report Share Posted December 12, 2014 (edited) Variables: 7x 1-Dimensional Array Variable: // VARIABLES //1D Array (Blow Up Code) unsigned int MtxRow0[8]={0}; unsigned int MtxRow1[8]={0}; unsigned int MtxRow2[8]={0}; unsigned int MtxRow3[8]={0}; unsigned int MtxRow4[8]={0}; unsigned int MtxRow5[8]={0}; unsigned int MtxRow6[8]={0}; unsigned int MtxRow7[8]={0}; //Initalize LED-Matrix for(tmpCount=0; tmpCount<8; tmpCount++){ //=0: StartValue, <7: under 7Cycles?, tmpCount++: MatrixRow0[tmpCount]=1; //fill the Matrix to test the hardware MatrixRow1[tmpCount]=1; MatrixRow2[tmpCount]=1; MatrixRow3[tmpCount]=1; MatrixRow4[tmpCount]=1; MatrixRow5[tmpCount]=1; MatrixRow6[tmpCount]=1; MatrixRow7[tmpCount]=1;} //Matrix 1:1 Routing MatrixRow0[0]=0; MatrixRow1[1]=0; MatrixRow2[2]=0; MatrixRow3[3]=0; MatrixRow4[4]=0; MatrixRow5[5]=0; MatrixRow6[6]=0; MatrixRow7[7]=0; or1x 2-Dimensional Array Variable: Mtx[8][8] //Have ERRORS later in the program // VARIABLES //2D Array (the way to go) unsigned int Mtx[8][8]; unsigned int MtxCount; unsigned int MtxCountOffset; unsigned int MtxCount_H; unsigned int MtxCount_V; // INITALIZE //////////////////////////////////////////////////////////////// void Init(void) __wparam{ //Initalize 2D-Array-LED-Matrix ---Workaround for(tmpCount=0; tmpCount>8; tmpCount++) //=0: StartValue, <7: under 7Cycles?, tmpCount++: +1everycycle {Mtx[0][tmpCount]=1; //fill the Matrix to test the hardware Mtx[1][tmpCount]=1; Mtx[2][tmpCount]=1; Mtx[3][tmpCount]=1; Mtx[4][tmpCount]=1; Mtx[5][tmpCount]=1; Mtx[6][tmpCount]=1; Mtx[7][tmpCount]=1;} Errors on my Way: unsigned int Mtx[8][8]={0}; main.c:198: error 69: struct/union/array 'MtxRow': initialization needs curly braces Caught signal 11: SIGSEGV ergo I cant initalize that way.... nor this way: // VARIABLES --- Global & Local /////////////////////////////////////////////////// unsigned int Mtx[8][8]={{}}; main.c:193: syntax error: token -> '}' ; column 29 Edited December 13, 2014 by Phatline Quote Link to comment Share on other sites More sharing options...
Phatline Posted December 12, 2014 Author Report Share Posted December 12, 2014 (edited) 2. CODE Striped Down: with 1D Array Variables // main.c // 8x8 LED-Matrix-Test // The Program light up all 64 LEDs ///////////////////////////////////////////////////////////////////////////// //Include files #include <cmios.h> #include <pic18fregs.h> #include "main.h" ///////////////////////////////////////////////////////////////////////////// // VARIABLES - - - Description of Variables can be found in void init(void) __wparam! ///////////////////////////////////////////////////////////////////////////// app_flags_t app_flags; // status of app (see bitfield declaration in main.h) unsigned int MtxCount; unsigned int MtxCount_H; int MtxDoutV; int MtxDoutH; int MtxDoutVtmp; int MtxDoutHtmp; int MatrixRow0[8]={1}; //Fill-Initialize the Matrix with 1 > LEDs should ligth up int MatrixRow1[8]={1}; //1D because for me 2D Arrays give me Strange Errors in Mios8 int MatrixRow2[8]={1}; int MatrixRow3[8]={1}; int MatrixRow4[8]={1}; int MatrixRow5[8]={1}; int MatrixRow6[8]={1}; int MatrixRow7[8]={1}; ///////////////////////////////////////////////////////////////////////////// // INITALIZE //////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// void Init(void) __wparam{ //DIN DOUT AIN Setup MIOS_SRIO_UpdateFrqSet(1); //set shift register update frequency in ms MIOS_SRIO_NumberSet(12); // we need to set at least one IO shift register pair //Set Number of DOUT-Register where the LED Matrix is connected (start by 0) MtxDoutVtmp = 10; //Nr.off Vertikal Shiftregister - 0 is the First Register!!!!!! MtxDoutHtmp = 11; //Nr.off Horizontal Shiftregister - 0 is the First Register!!!!!! MtxDoutV = MtxDoutVtmp * 8; //DOUT-PIN-Calculation: Vertikal Shiftregister MtxDoutH = MtxDoutHtmp * 8; //DOUT-PIN-Calculation: Horizontal Shiftregister MtxCount_H = 0; //Horizontal Counter init > must be 0 > dont Change! } ///////////////////////////////////////////////////////////////////////////// // This function is called by MIOS before the shift register are loaded (every ms) ///////////////////////////////////////////////////////////////////////////// void SR_Service_Prepare(void) __wparam{ /////////DOUT-Matrix-routine///////// //Deactivate Vertical PINs (from last cycle) MIOS_DOUT_PinSet( MtxDoutV, 0); //MtxDoutV= Number of HC595Register - Predefinied e.g.10 MIOS_DOUT_PinSet((MtxDoutV+1), 0); //HC595 OUT-PORTs=8 MIOS_DOUT_PinSet((MtxDoutV+2), 0); //+2 is the 3rd (starting by 0) Pin of this Registor MIOS_DOUT_PinSet((MtxDoutV+3), 0); //so: (10x8=80)+3 = 83.Pin MIOS_DOUT_PinSet((MtxDoutV+4), 0); MIOS_DOUT_PinSet((MtxDoutV+5), 0); MIOS_DOUT_PinSet((MtxDoutV+6), 0); MIOS_DOUT_PinSet((MtxDoutV+7), 0); //Deactivate the last Horizontal PIN (from last cycle) MIOS_DOUT_PinSet(MtxCount_H, 0); MtxCount_H = MtxDoutH+MtxCount; //MtxDoutH=Number of Connected Register*8=Pin Number //Activate Vertical Lines MIOS_DOUT_PinSet( MtxDoutV, MatrixRow0[MtxCount]); MIOS_DOUT_PinSet((MtxDoutV+1), MatrixRow1[MtxCount]); MIOS_DOUT_PinSet((MtxDoutV+2), MatrixRow2[MtxCount]); MIOS_DOUT_PinSet((MtxDoutV+3), MatrixRow3[MtxCount]); MIOS_DOUT_PinSet((MtxDoutV+4), MatrixRow4[MtxCount]); MIOS_DOUT_PinSet((MtxDoutV+5), MatrixRow5[MtxCount]); MIOS_DOUT_PinSet((MtxDoutV+6), MatrixRow6[MtxCount]); MIOS_DOUT_PinSet((MtxDoutV+7), MatrixRow7[MtxCount]); //Activate Horizontal Line MIOS_DOUT_PinSet(MtxCount_H, 1); //Activate First Row - Negatives Side of Diodes //Counter - count from 0-7 then 0 again... if (MtxCount < 8) {MtxCount = MtxCount + 1;} if (MtxCount > 7) {MtxCount = 0;} } void Tick(void) __wparam{} void Timer(void) __wparam{} void DISPLAY_Init(void) __wparam{} void DISPLAY_Tick(void) __wparam{} void MPROC_NotifyReceivedEvnt(unsigned char evnt0, unsigned char evnt1, unsigned char evnt2) __wparam{} void MPROC_NotifyFoundEvent(unsigned entry, unsigned char evnt0, unsigned char evnt1, unsigned char evnt2) __wparam{} void MPROC_NotifyTimeout(void) __wparam{} void MPROC_NotifyReceivedByte(unsigned char byte) __wparam{} void SR_Service_Finish(void) __wparam{} void DIN_NotifyToggle(unsigned char pin, unsigned char pin_value) __wparam{} void ENC_NotifyChange(unsigned char encoder, char incrementer) __wparam{} void AIN_NotifyChange(unsigned char pin, unsigned int pin_value) __wparam{} wy i use MIOS_DOUT_PinSet instead of MIOS_DOUT_SRSet? >because I dont know better! Edited December 13, 2014 by Phatline Quote Link to comment Share on other sites More sharing options...
Phatline Posted December 12, 2014 Author Report Share Posted December 12, 2014 (edited) 3.Matrix-Buttons (2x8 aka 64xVirtual Buttons>the matrix) While i dont have problems with 1Dimensional Arrays. I have massiv Problems with the 2 Dimensional Arrays. following codes are working: if((TrgBtnOut[0]==1 && TrgBtnIn[0]==1)){Matrix[0][7] =! Matrix[0][7];} if((TrgBtnOut[0]==1 && TrgBtnIn[1]==1)){Matrix[1][0] =! Matrix[1][0];} these not: (Matrix[2][0] - Matrix[7][0] making troubles if((TrgBtnOut[0]==1 && TrgBtnIn[2]==1)){Matrix[2][0] =! Matrix[1][0];} if((TrgBtnOut[0]==1 && TrgBtnIn[2]==1)){Matrix[2][0] =! Matrix[2][0];} if((TrgBtnOut[0]==1 && TrgBtnIn[1]==1)){Matrix[2][0] =! Matrix[2][0];} Error: _Matrix + 33)(7) == _Matrix + 1)(7) sdcc: /home/sdcc-builder/build/sdcc-build/orig/sdcc/src/pic16/pcode.c:9278: pic16_OptimizeBanksel: Assertion `0 && "Could not assign a symbol to a bank!"' failed. Caught signal 6: SIGABRT make: *** [_output/main.o] Fehler 1 Edited December 13, 2014 by Phatline Quote Link to comment Share on other sites More sharing options...
Phatline Posted December 13, 2014 Author Report Share Posted December 13, 2014 (edited) ok i dont do this with 2D Arrays - it dont work for me --- --- 1D give me at least no errors schade Edited December 13, 2014 by Phatline Quote Link to comment Share on other sites More sharing options...
TK. Posted December 13, 2014 Report Share Posted December 13, 2014 "=!" isn't a valid C operator, try "!=" Best Regards, Thorsten. Quote Link to comment Share on other sites More sharing options...
Phatline Posted December 13, 2014 Author Report Share Posted December 13, 2014 (edited) @TK: i will give it a try if it works - i will post a Stripped Down 2D Array Code its a good Idea, bevore you connect the matrix, to connect simple Diodes, the troubleshooting and programming with that is much easier (if you are an C-NewBee like me) AND it WORKS: https://vimeo.com/114452009 And here is the stripped down 1D-Array code for a 8x8LED-Matrix for 8Bit Core: Edited December 14, 2014 by Phatline Quote Link to comment Share on other sites More sharing options...
Phatline Posted December 13, 2014 Author Report Share Posted December 13, 2014 "=!" isn't a valid C operator, try "!=" Code with != and 2D Arrays (1D no problem) if((TrgBtnOut[0]==1 && TrgBtnIn[0]==1)){Matrix[0][0] != Matrix[0][0];} main.c:641: warning 110: conditional flow changed by optimizer: so said EVELYN the modified DOG :puppeh: humor? Code with =! and 2D Arrays (1D no problem) if((TrgBtnOut[0]==1 && TrgBtnIn[0]==1)){Matrix[0][0] =! Matrix[0][0];} _Matrix + 127)(7) == _Matrix + 95)(7) sdcc: /home/sdcc-builder/build/sdcc-build/orig/sdcc/src/pic16/pcode.c:9278: pic16_OptimizeBanksel: Assertion `0 && "Could not assign a symbol to a bank!"' failed. Caught signal 6: SIGABRT make: *** [_output/main.o] Fehler 1 I stay by 1D Arrays. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.