Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Written by Nick Gammon.
- // February 2011. PB: going to test three-pin PCINT0_vect
- //SS pin interrupt OK and receiving two adr Hi and Lo from Master with 2uS delay
- /* Fri Jul 3 11:02:43 NZST 2020. Thu Jul 9 15:07:04 NZST 2020 C:\Users\Dell\Documents\Arduino\PB_Sketches_May20\spi0SlaveA\spi0SlaveA.ino
- Fri Jul 10 11:08:13 NZST 2020. Not working well reading addresses.
- Sun Jul 12 12:50:23 NZST 2020. After 3 days work, back going ok. Fetch,execute problems and stray data. Given
- ..up on Pin Change with SS. At last, working OK. Just timing problems, I think.
- Mon Jul 13 11:50:24 NZST 2020 Now starting to add old parts of CDP1802f03.ino that worked on Arduino Mega
- Tue Jul 14 11:08:16 NZST 2020. Now trying check for commands etc.
- Wed Jul 15 11:56:17 NZST 2020 C:\Users\Dell\Documents\Arduino\PBSketchesjul2020\spi0SlaveF\spi0SlaveF.ino
- ..trying readstrobe stuff.Wed Jul 15 12:35:40 NZST 2020. Writing using writeStrobe seems to work.
- ..Now trying getFile so don't have to write hex bytes at top of this file.OK worked.
- Now going to try running in high adr =$4000. Forth inner interp goes OK in VRAM. Thu Jul 23 12:03:55 NZST 2020
- Sat Jul 25 11:56:43 NZST 2020. All OK outputting hex, now want to do disassembly. INvestigate first: printLevel
- Added several important routines and flash table for disassem. May need some work to integrate CDP1802f03
- .. with two nano system. Wed Jul 29 12:36:21 NZST 2020. Going OK . Now insert single stepping.
- Fri Jul 31 12:32:31 NZST 2020. Now going to add breakpoint routines. Versioning got confused around K,L
- Sat Aug 1 12:44:58 NZST 2020: starting to integrate opcode stopping.
- Thu Aug 6 13:11:13 NZST 2020. Works OK. As do printLevels. with <de00> get fastest rate , about 26K
- ..for clock rate. Nearly finished. Do we need to turn commands on,off? Finally need to run a bigger prog.
- ..eg. forth1802A5.asm
- */
- #include <SPI.h>
- #include <avr/pgmspace.h> //not needed? Maybe will be needed with disassembly
- #define clockTo1802Pin 3
- #define SSpin 10
- #define clearPin 18//A4
- #define SCOPin 2
- #define MRDPin 8
- #define writePin 9
- const byte numChars = 32;
- char receivedChars[numChars];
- char char3 = '7' ;
- char char4 ='F';
- char oldChar4;
- char data0[10] ;
- char closingBracket;
- char ch1;
- char instructionBytes = 1; //some instructions have 1 eg c4 = nop, some have 3 eg lsk 12 34
- byte receivedBytes[numChars];
- volatile byte c;
- boolean newData = false;
- boolean showCommands=true;
- unsigned long t0,clkCtr=0,TPBCtr= 0, clockRate=0,t1=0; //used in millis timing.
- unsigned long time =0;
- unsigned int breakPointAdr=0,stopCode;
- volatile boolean SSFell2 = true;
- uint16_t PB2Ints=0;
- uint16_t SSFallen=0;
- uint16_t DELAY = 32; //32; //100;
- uint16_t BUFFERLENGTH = 256 ; //1024; //this is how big the vRAM[] array is. Going to be shorter than 1024.
- uint16_t SPIintNUm=0;
- uint16_t ISRNum =0;
- uint16_t currentAdr=0;
- uint16_t opCode; //shoud be byte?
- uint16_t fetchCtr=0;
- int printLevel=3; //2; //how much detail do you want in serial output for disassembler
- char fetchOrExecute ='N'; //neither at the start
- char readOrWriteCh;
- char data[100] ;
- byte adr0 = 0; //this is high adr byte. adr1 is lo byte
- byte adr1 = 0;
- byte LSNib;
- byte MSNib;
- byte nextByte;
- byte thirdByte;
- boolean gotAdr = false;
- boolean fetchFlag = false;
- boolean MRDFlag = false;
- boolean writeStrobe = false;
- boolean foundOpCode;
- boolean singleStepping = false, stepMe=false;
- boolean doOpStops = false; //breakpoint if opCode=stopCode;
- const char flashHiNib3[] PROGMEM = {"[00idl.][01ldn.L[10inc.L[20dec.L[30br.N[31bq.N[32bz.N[33bdf.N[34b1.N[35b2.N[36b3.N[37b4.N[38skp.][39bnq.N[3Abnz.N[3Bbnf.N[3Cbn1.N[3Dbn2.N[3Ebn3.N[3Fbn4.N[40lda.L[50str.L [60irx.L[61out.L[69inp.L[70ret.]abcd[71dis.][72ldxa.][73stxd][74adc.][75sdb.][76shrc.][77smb.][78sav.][79mark.][7Aseq.][7Breq.][7Caddi.N[7Dsdbi.N[7Eshlc.][7Fsmbi.N[80glo.L[90ghi.L[A0plo.L[B0phi.L[C0lbr.T[C1lbq.T[C2lbz.T[C3lbdf.T[C4nop.][C5lsnq.][C6lsnz.][C7lsnf.][C8lskp.][C9lbnq.T[CAlbnz.T[CBlbnf.T[CClsie.][CDlsq.][CElsz.][CFlsdf.][D0sep.L[E0sex.L[F0ldx.][F1or.][F2and.][F3xor.][F4add.][F5sd.][F6shr.][F7sm.][F8ldi.N[F9ori.N[FAani.N[FBxri.N[FCadi.N[FDsdi.N[FEshl.][FFsmi.N"}; //};
- //byte vRAM[5] = {0x7b, 0x7b, 0x7a, 0x7b, 0x00}; //seq is 7b (wrong in RCA book)
- //byte vRAM[20] = {0x7b,0x7a,0x7a,0x7a,0x7a,0xc4,0xc4,0x7b,0x7a,0x30,0x05,0x00}; //seq is 7b, led on with req. (wrong in RCA book)
- //byte vRAM[256] = {0x7b,0x7a,0x7a,0x7a,0x7a,0xc4,0xc4,0x7b,0x7a,0x30,0x05,0x00};
- byte vRAM[256] = {0x7b,0x7a,0xf8,0,0xb2,0xf8,0xf8,0xa2,0xf8,0xa6,0x52,0x7a,0xc4,0xc4,0x7b,0x7a,0x30,0x0c,0x00};
- //byte vRAM[256] = {0xc4, 0xc0, 0x40, 0x00, 0x7b,0x7a,0x7a,0x7a,0x7a,0xc4,0xc4,0x7b,0x7a,0x30,0x05,0x00}; // just jump to highadr = $4000
- void setup (void) {
- pinMode(clockTo1802Pin,OUTPUT); //D3 goes to 1802 clock
- pinMode(SSpin,INPUT);
- pinMode(clearPin,OUTPUT);
- pinMode(SCOPin,INPUT);
- pinMode(MRDPin,INPUT);
- Serial.begin (115200); // debugging
- serialFlush();
- delay(500); //time to sort out Bray++
- Serial.flush();
- doReset();
- SPCR =(1<<SPE); // turn on SPI in slave mode
- pinMode(MISO, OUTPUT); // have to send output on master in, *slave out*
- SPI.attachInterrupt();
- SPDR=0; //to start off with
- dumpVariableVert(256); //**
- } // end of setup
- // SPI interrupt routine
- ISR (SPI_STC_vect) { //only want to come here when SS pin is low
- c = SPDR; // grab byte from SPI Data Register
- if (SSFell2==true){
- adr0=c;
- SSFell2=false;
- } else {
- adr1=c; //adr1 is low adr
- gotAdr=true;
- SSFell2=true;
- } //need 2uS gap between adresses to make this work.
- SPIintNUm++ ;
- //next, quickly get status flags before too late.
- if (digitalRead(SCOPin) == LOW ) fetchFlag = true; else fetchFlag=false;
- if (digitalRead(MRDPin) == LOW) MRDFlag = true; else MRDFlag = false;
- // end of interrupt routine SPI_STC_vect
- }
- //-----------------------------
- void loop (void) {
- checkForCommands();
- doClockCycle();
- } //---------------------
- void doClockCycle(void) {
- digitalWrite(clockTo1802Pin,HIGH);
- if (digitalRead(writePin)==LOW){
- writeStrobe=true;
- //doInpStuffIfNecess();
- }
- delay(DELAY);
- digitalWrite(clockTo1802Pin,LOW);
- if ( gotAdr==true) {
- doGotAdr();
- TPBCtr++; //Serial.print(TPBCtr);Serial.print(" ");Serial.println(clkCtr);
- }
- clkCtr++;
- delay(DELAY);
- }
- void doGotAdr(void) {
- if (MRDFlag==true) {
- currentAdr = adr1+adr0*256;
- //Serial.print("~~~currentAdr");Serial.println(currentAdr,HEX);
- if (adr0 ==0) { //if low adr it's in vRAM array, otherwise lives in high flash
- opCode = vRAM[currentAdr];
- sendToBus(vRAM[adr1]);
- nextByte = vRAM[currentAdr+1];
- thirdByte = vRAM[currentAdr+2];
- }
- else {
- opCode = pgm_read_byte(currentAdr);
- sendToBus(pgm_read_byte(currentAdr)); //must have been a hihg byte in flash $4000+
- nextByte = pgm_read_byte(currentAdr+1);
- thirdByte = pgm_read_byte(currentAdr+2);
- }
- if(printLevel!=0) {
- printTPBResults5();
- }
- if(singleStepping==true){
- Serial.print("*");
- stepMe=false;
- while(stepMe==false){
- checkForCommands();
- }
- }
- if((currentAdr==breakPointAdr) && (breakPointAdr>0)) {
- Serial.println("Breakpoint address .....");
- singleStepping=true;
- }
- if((doOpStops==true) && (opCode == stopCode)){
- if (fetchFlag==true) { //works better with this extra fetchFlag condition
- Serial.println("Op code stop .....");
- singleStepping=true;
- }
- }
- }
- if (writeStrobe==true) {
- writeStrobe = false;
- vRAM[adr1] = getFRomBus();
- }
- gotAdr=false;
- }
- void sendToBus(byte b) { //works OK
- byte temp;
- DDRC = DDRC | 0x0f; //low nibble on PortC
- DDRD = DDRD | 0xf0;
- PORTC = (PORTC & 0xf0) | (b & 0x0f);
- PORTD = (PORTD & 0x0f) | ( b & 0xf0);
- if(fetchFlag==true) {
- fetchOrExecute ='F';
- fetchCtr++;
- //Serial.print(currentAdr,HEX);Serial.print(" is adr, and current opCode is ");Serial.print(opCode,HEX); Serial.print(" <-Fetch ");
- }
- else {
- //Serial.print(" execute ");
- fetchOrExecute='E';
- //Serial.print(fetchOrExecute);
- }
- if(MRDFlag==true) {
- //Serial.println(" Read4 ");
- readOrWriteCh = 'R';
- }
- else {
- Serial.println(" NoRead "); //@@@@@@@@@@@@
- readOrWriteCh = 'W';
- }
- }
- byte getFRomBus(void) { //used when !WRB goes low
- byte lob,hib,inpb;
- DDRC = DDRC & 0xf0; //low nibble on PortC
- DDRD = DDRD & 0x0f; //Maybe put these DDR commands up into calling fn to slow it down, before read.
- //Serial.print(DDRC,HEX);Serial.print(" <--DDRC and DDRD --> ");Serial.println (DDRD);
- //delay(1); //needed, PINC and PIND might need settling time
- delayMicroseconds(4); //needs this delay in order to read port properly after DDR change.
- lob= PINC & 0x0f;
- hib = PIND & 0xf0;
- inpb = (hib | lob );
- if (printLevel==3) {
- Serial.print ("-w-"); Serial.print(adr0,HEX);
- Serial.print(adr1,HEX);Serial.print(" is adr, and going into vRAM is ");Serial.println(inpb,HEX);
- }
- return inpb;
- }
- void doReset(void){
- Serial.println("Resetting---");
- digitalWrite(clearPin,LOW); //bring CLEAR low for about 10 clocks to reset 1802
- for(int i =0;i<=10;i++) {
- digitalWrite(clockTo1802Pin, HIGH);
- delay(DELAY);
- digitalWrite(clockTo1802Pin, LOW);
- delay(DELAY);
- }// 10 clocks low should reset 1802
- digitalWrite(clearPin,HIGH); //bring back to RUN mode
- }
- void serialFlush(void){
- while(Serial.available() > 0) { //while there are characters in the serial buffer, because
- char t = Serial.read(); // get one character
- }
- }
- void dumpVariableVert(int sizeToDump) { //From old mega based version
- Serial.print("Col: ");
- for(int i=0;i<16;i++) {
- sprintf(data, "%02x ",i);
- Serial.print(data);
- if(i==7) Serial.print(" ");
- }
- for (int i=0;i<sizeToDump;i++){
- if (i%16 == 0){
- Serial.println ("");
- sprintf(data, "%02x ",i);
- Serial.print(data);
- }
- if(i%8==0) { Serial.print("|"); }
- sprintf(data, " %02x ",vRAM[i]);
- Serial.print(data);
- }
- Serial.println(" ");
- }
- //printTPBResults4 seems to be best output routine from old mega code
- void checkForCommands(){ //if any inputs from keyboard, push them into buffer and see what command it is.
- recvWithStartEndMarkers();
- showAndInterpret();
- }
- void recvWithStartEndMarkers() { ////https://forum.arduino.cc/index.php?topic=396450
- static boolean recvInProgress = false;
- static byte ndx = 0;
- char startMarker = '<';
- char endMarker = '>';
- char rc;
- while (Serial.available() > 0 && newData == false) {
- rc = Serial.read();
- if (recvInProgress == true) {
- if (rc != endMarker) {
- receivedChars[ndx] = rc;
- receivedBytes[ndx]=(byte)rc; //PB added this
- ndx++;
- if (ndx >= numChars) {
- ndx = numChars - 1;
- }
- }
- else {
- receivedChars[ndx] = '\0'; // terminate the string
- recvInProgress = false;
- ndx = 0;
- newData = true;
- }
- }
- else if (rc == startMarker) {
- recvInProgress = true;
- }
- }
- }
- void showAndInterpret() {
- if (newData == true) {
- if(showCommands==true){
- Serial.print("Command received is : ");
- Serial.println(receivedChars);
- }
- else {serialFlush();} //get rid of commands in input buffer
- interpretCommand();
- //interpretCommand(); //*******put back** just testing for ram size
- newData = false;
- }
- }
- void interpretCommand() {
- // String Command(receivedChars); //**important
- //if(Command.equals("gf")){
- if((receivedBytes[0]=='g')&&(receivedBytes[1]=='f')) { //get file
- Serial.print("Send file");
- getFile();
- Serial.print(" Not working yet in two nano system.");
- serialFlush();
- doReset();
- }
- if((receivedBytes[0]=='d')&&(receivedBytes[1]=='u')) { //dump 256 bytes;"du"
- dumpVariableVert(256);
- serialFlush();
- }
- if((receivedBytes[0]=='r')&&(receivedBytes[1]=='e')) { //"re" for reset
- doReset();
- TPBCtr=0; clkCtr = 0;
- serialFlush();
- Serial.println(F("**done gf flush** Now resetting"));
- }
- if((receivedBytes[0]=='s')&&(receivedBytes[1]=='s')){ //single step; "ss"
- singleStepping=true; t1=millis()-time; Serial.print("--> ");Serial.print(t1);
- clockRate = (clkCtr*1000)/t1; Serial.print("=&& "); Serial.println(clockRate);
- } //go into single stepping but stop clock; presume <run> just finished.
- if((receivedBytes[0]=='s')&&(receivedBytes[1]=='t')) stepMe=true; //"st"
- if((receivedBytes[0]=='r')&&(receivedBytes[1]=='u')) { //"ru"; run
- singleStepping=false;
- stepMe=true;
- Serial.println("Sing step = false");
- clkCtr=0; TPBCtr=0; fetchCtr=0; //after "run" we're timing clks/sec
- time=millis();
- }
- if((receivedBytes[0]==0x64)&&(receivedBytes[1]==0x65)) doDelay(); //<dexx>.
- if((receivedBytes[0]==0x62)&&(receivedBytes[1]==0x70)) doBreakPoint2();
- if((receivedBytes[0]==0x6f)&&(receivedBytes[1]==0x70)) doOpStop2(); //<opxx>
- if((receivedBytes[0]=='o')&&(receivedBytes[1]=='s')) { //os ; opstop toggle
- if(doOpStops==true) doOpStops=false;
- else doOpStops=true;
- }
- if((receivedBytes[0]=='r')&&(receivedBytes[1]=='p')) doReport2(); //doReport(); //rp
- if((receivedBytes[0]=='p')&&(receivedBytes[1]=='0')) printLevel=0; //p0
- if((receivedBytes[0]=='p')&&(receivedBytes[1]=='1')) printLevel=1; //p1
- if((receivedBytes[0]=='p')&&(receivedBytes[1]=='2')) printLevel=2; //p2
- if((receivedBytes[0]=='p')&&(receivedBytes[1]=='3')) printLevel=3; //p3
- }
- void getFile() { // go to File Send part of Bray++ terminal and put bin file into vRAM[]
- int inCtr=0;
- byte byteIn=65;
- while(inCtr<BUFFERLENGTH){
- if(Serial.available()){
- byteIn = Serial.read();
- vRAM[inCtr]=byteIn;
- inCtr++;
- }
- }
- Serial.print("Got "); Serial.println(BUFFERLENGTH);
- }
- void doDelay() {
- unsigned int hexVal[8];
- hexVal[2]=hexCharToInt2(receivedBytes[2])*16;
- hexVal[3]=hexCharToInt2(receivedBytes[3])*1;
- DELAY=hexVal[2]+hexVal[3];
- Serial.print("DELAY now is : ");
- Serial.print(DELAY);
- Serial.print(", in hex : 0x");
- Serial.println(DELAY,HEX);
- }
- void printTPBResults5(void) { //this fn taken mostly from CDP1802f03.asm
- Serial.print("[");
- if (fetchOrExecute=='F'){
- sprintf(data," %02x%02x : ",adr0,adr1);
- Serial.print(data);
- //Serial.print(fetchOrExecute);
- //doDisAsm(opCode); //old .
- doDisLine(opCode); //BIG connection with new progmem code
- if (printLevel==1) { //@@@@@@@@@keep print level at 1 for time being
- Serial.println("]"); //if level1 finish here with CR..
- }
- if(printLevel>=2) {
- sprintf(data," --%2x ",opCode);
- Serial.print(data);
- if(closingBracket==']') {Serial.println(); }
- if(closingBracket=='L') {Serial.println();} //Serial.println(LSNib,HEX);
- if(closingBracket=='N') Serial.println(nextByte,HEX); //eg br 34.
- if(closingBracket=='T') {
- //Serial.print(nextByte,HEX);
- //Serial.println(thirdByte,HEX);
- //Serial.print(closingBracket);
- sprintf(data," %02x%02x ",nextByte,thirdByte);
- Serial.print(data);
- } /*
- //if (instructionBytes ==1) Serial.println(data);
- if (instructionBytes==2) {
- //Serial.print(data);
- //Serial.println(vRAM[currentAdr+1],HEX); //nextByte = vRAM[currentAdr+1];
- //Serial.println(nextByte,HEX);
- }
- if (instructionBytes==3) {
- //Serial.print(data);
- //Serial.print(vRAM[currentAdr+1],HEX);
- //Serial.println(nextByte,HEX);
- //Serial.println(vRAM[currentAdr+2],HEX); //thirdByte = vRAM[currentAdr+2];
- //Serial.println(thirdByte,HEX);
- } */
- }
- }
- else { // ie it's not 'F', it's an execute line:
- if(printLevel==3) { //*************pit back
- sprintf(data," Adr: %x%x : %02x Ck=%lu, Cy=%lu, Fc=%u ; ( %c %c ) M%lu Cr%lu",adr0,adr1,opCode,clkCtr,TPBCtr,fetchCtr, fetchOrExecute,readOrWriteCh,t1,clockRate);
- // sprintf(data," Adr: %x%x : %02x Ck=%lu, Cy=%lu, In=%lu ; ( %c %c ) M%lu Cr%lu",adr0,adr0,opCode,clkCtr,TPBCtr,fetchCtr, fetchOrExecute,readOrWriteCh,t1,clockRate);
- //sprintf(data,"Adr: %x%x : %02x %u, %u ,%u ; %c %c",adrByteHi,adrByte,opCode,TPBCtr,clkCtr,fetchCtr, fetchOrExecuteCh,readOrWriteCh);
- //sprintf(data," Adr: %x%x : %02x %u, %u %c %c",adrByteHi,adrByte,opCode,TPBCtr,clkCtr, fetchOrExecuteCh,readOrWriteCh);
- Serial.println(data);
- //Serial.println(fetchOrExecute);
- }
- }
- }
- //next routines come from CDP1802f03.asm
- void doDisLine( byte opC) { //go into big progrmem string and emrge with j pointing opening '[' of menonic substring
- opCodePreProcess(opC);
- int k=0;
- foundOpCode= false;
- while ((k < strlen_P(flashHiNib3)) && (foundOpCode==false)){
- ch1 = pgm_read_byte_near(flashHiNib3+k);
- if (ch1=='[') {
- if( (pgm_read_byte_near(flashHiNib3+k+1)==char3) && (pgm_read_byte_near(flashHiNib3+k+2) ==char4) ){
- foundOpCode=true;
- data0[0] = pgm_read_byte_near(flashHiNib3+k+3); //first char of mnemonic
- data0[1] = pgm_read_byte_near(flashHiNib3+k+4);
- data0[2] = pgm_read_byte_near(flashHiNib3+k+5);
- data0[3] = pgm_read_byte_near(flashHiNib3+k+6);
- data0[4] = pgm_read_byte_near(flashHiNib3+k+7);
- data0[5] = pgm_read_byte_near(flashHiNib3+k+8);
- if (data0[2] == '.') closingBracket = data0[3]; //two char menonic like br
- if (data0[3] == '.') closingBracket = data0[4]; //3 char mnem like lda.
- if (data0[4] == '.') closingBracket = data0[5];
- }
- }
- k++;
- }
- if (foundOpCode==false) {
- Serial.print(F("Don't understandop code "));
- Serial.println(opC,HEX);
- }
- else {
- fixData0(); // now the nemonic ends with trailing \0
- Serial.print (data0); //print the mnemonic..
- doClosingBrackets(); //..and any other addresses etc
- }
- }
- //
- void opCodePreProcess(byte opCo0) {
- MSNib = opCo0/16;
- LSNib = opCo0%16;
- char3 = binToAsc(MSNib);
- char4= binToAsc(LSNib);
- if ((char3 =='8')||(char3 =='9') || (char3 =='A')|| (char3 =='B')) { oldChar4 = char4; char4='0'; } //glo,ghi,plo,phi resp
- if (char3=='0') { if (LSNib>0) {oldChar4 = char4; char4='1';}} //ldn but n!=0
- if ((char3=='1') || (char3=='2')) {oldChar4 = char4; char4='0';} //inc, dec
- if ((char3=='4') || (char3=='5')) {oldChar4 = char4; char4='0';} //lda,str
- if (char3=='6') {
- if ((LSNib>0) && (LSNib<=7)){oldChar4 = char4; char4='1';} //out n but n!=0 and n<=7
- if (LSNib>8) {oldChar4 = char4; char4='9';LSNib=LSNib-8;} //inp n but n>8. NB 68 seems to be invalid opCode
- }
- if ((char3=='D') || (char3=='E')) {oldChar4 = char4; char4='0';} //sep,sex
- }
- byte binToAsc(byte b) { //eg change 0x03 to 0x33 = '3'
- byte temp;
- temp = b + 0x30;
- if (temp > 0x39) temp = temp +7; // adjust for hex. NB outputs capital A,B etc
- return temp;
- }
- //
- void fixData0(void) { //replace dot with space and \0 so it prints OK
- for (int i = 0;i<10;i++) {
- if (data0[i] == '.') {
- data0[i] = ' ';
- data0[i+1] ='\0';
- }
- }
- }
- void doClosingBrackets(void) { //going to change printlns to prints below. To work in with old software display..
- if(closingBracket==']') { }; // Serial.print("."); //nothing after mnemonic eg nop
- if(closingBracket=='L') Serial.print(LSNib,HEX); //eg phi 3
- if(closingBracket=='N') Serial.print(nextByte,HEX); //eg br 34.
- if(closingBracket=='T') {
- Serial.print(nextByte,HEX);
- Serial.print(thirdByte,HEX);
- }
- }
- int hexCharToInt2(byte by){ //pb version
- int d,r;
- d=by-'0';
- if(d>=0 && d<=9) {r=d;}
- else{
- d=by-55; //is it A,B...F?
- if (d>=10 && d<=15) {r=d;}
- else{
- r=by-87; //must be a,b...f. NB No error checking.
- }
- }
- return r;
- }
- void doBreakPoint2(){
- int d;
- int ctr=0;
- unsigned int hexVal[8];
- hexVal[2]=hexCharToInt2(receivedBytes[2])*4096;
- hexVal[3]=hexCharToInt2(receivedBytes[3])*256;
- hexVal[4]=hexCharToInt2(receivedBytes[4])*16;
- hexVal[5]=hexCharToInt2(receivedBytes[5])*1;
- breakPointAdr=hexVal[2]+hexVal[3]+hexVal[4]+hexVal[5]; //important
- Serial.print("Break point adress is : ");
- Serial.print(breakPointAdr);
- Serial.print(", in hex : 0x");
- Serial.println(breakPointAdr,HEX);
- }
- void doOpStop2(){
- // int d;
- unsigned int hexVal[8];
- hexVal[2]=hexCharToInt2(receivedBytes[2])*16;
- hexVal[3]=hexCharToInt2(receivedBytes[3])*1;
- stopCode=hexVal[2]+hexVal[3];
- Serial.print("Op stop is : ");
- Serial.print(stopCode);
- Serial.print(", in hex : 0x");
- Serial.println(stopCode,HEX);
- }
- void doReport2() { //old doReport takes up too much RAM
- Serial.println (F("delay,op-Stop code, breakpoint"));
- Serial.println(DELAY);
- Serial.println(stopCode,HEX);
- Serial.println(breakPointAdr);
- }
Add Comment
Please, Sign In to add comment