Need some help with assembly language in code for morse transmitter [AM]

Hello there,

as my topic title says,
I got a question about some assembly code in the sketch that I have copied and edited,

From this topic:

I got ordered a lcd - keypad shield from a local seller yesterday, and have a problem with the ports that are needed for the lcd shield to work,

as I have read the code has assembly in it to set some ports as output (I think pin 8 - 13) and now I need to set this to pwm pin 3 on the digital pin header in order to get the transmitter to work hand in hand with the lcd shield,

can someone tell me how to do it?
so I can transmit on pin 3 and also have an working lcd

tnx already in advance,

Best Regards,
Bradley Methorst (DragonicDefson)

Maybe This Will Help:

long milliseconds_at_start = 0;
long milliseconds_at_end = 0;

const long length_transmitting_period = 8;

#define length_trans_dot 64

const int length_dot = length_trans_dot;
const int pause_dot = length_trans_dot;
const int length_dash = 3 * length_trans_dot;
const int pause_dash = length_trans_dot;
const int pause_words = 7 * length_trans_dot;

char * Letters[] =
{
 ".-", "-...", "-.-.", "-..", ".", "..-.", "--.", "....", "..",    // A-I
 ".---", "-.-", ".-..", "--", "-.", "---", ".--.", "--.-", ".-.",  // J-R
 "...", "-", "..-", "...-", ".--", "-..-", "-.--", "--.."          // S-Z
};

char * numbers[] = {"-----", ".----", "..---", "...--", "....-", ".....", "-....", "--...", "---..", "----."};

void dot (void); 
void dash (void);
void pause (void);

void start_transmitting (int n_cycles);
void stop_transmitting (int n_cycles);

#define ASM_INC(reg) asm volatile ( "inc %0" : "=r" (reg) : "0" (reg))

void setup()  
{
 
  Serial.begin(9600);
 
  DDRD = DDRD|B00001000;
 
  milliseconds_at_start = millis();
 
  dot();
 
  milliseconds_at_end = millis();

  Serial.println();
  Serial.println( length_dot + (pause_dot * length_transmitting_period) * 256 / (milliseconds_at_end - milliseconds_at_start / 2 ));
  Serial.println();
  Serial.println( "\\-- BETTER_SOFTWARE_DEVELOPING MORSE_CODE PROJECT ANNO_2017 --//" );
  Serial.println();
  Serial.println( "[SYSTEM][ARDUINO]  [OI]POWER  ON[IO]  [ARDUINO][SYSTEM]" );
  Serial.println( "[TRANSMITTER] :FREQ :TRANSM|ITTING: FREQ: [TRANSMITTER]" );
  Serial.println( "[TRANSMITTER] :FREQUENCY:[KHZ]:FREQUENCY: [TRANSMITTER]" );
  Serial.println( "[TRANSMITTER] :FREQ :TRANSM|ITTING: FREQ: [TRANSMITTER]" );
  Serial.println( "[SYSTEM][ARDUINO]  [OI]POWER  ON[IO]  [ARDUINO][SYSTEM]" );
  Serial.println();
  Serial.println( "//-- BETTER_SOFTWARE_DEVELOPING MORSE_CODE PROJECT ANNO_2017 --\\" );
  Serial.println();
  Serial.println(length_dot + (pause_dot * length_transmitting_period) * 256 / (milliseconds_at_end - milliseconds_at_start / 2));
  Serial.println();

}

void loop()
{

    if (Serial.available() > 0)
    {
      char letter_number;

      letter_number = Serial.read();
    
      if (letter_number >= 'a' && letter_number <= 'z')
      {
        transmit_sequence(Letters[letter_number - 'a']);
      }
  
      else if (letter_number >= 'A' && letter_number <= 'Z')
      {
        transmit_sequence(Letters[letter_number - 'A']);
      }
  
      else if (letter_number >= '0' && letter_number <= '9')
      {
        transmit_sequence(numbers[letter_number - '0']);
      }
  
      else if (letter_number == ' ')
      {
        pause();
      }
    }
  }
  
  void transmit_sequence (char * sequence)
  {
    int i = 0;
      while (sequence[i] != NULL)
      {
        transmit_dot_dash (sequence[i]);
        i++;
      }
  pause();
  }

  void transmit_dot_dash (char dot_dash)
  {
    if (dot_dash == '.')
    {
      dot();          
    }
 
    else
    {
      dash();           
    }
  }

  void dot (void)
  {
    for (int i = 0; i < length_dot; i++)
    {
      start_transmitting (length_transmitting_period);
    }
    for ( int i = 0; i < pause_dot; i++)
    {
      stop_transmitting (length_transmitting_period);
    }
  }

  void dash (void)
  {
    for ( int i = 0; i < length_dash; i++ )
    {
      start_transmitting (length_transmitting_period);
    }
    for( int i = 0; i < pause_dash; i++ )
    {
      stop_transmitting (length_transmitting_period);
    }
  }

  void pause (void)
  {
    for(int i = 0; i < pause_words; i++)
    {
      stop_transmitting (length_transmitting_period);
    }
  }

  void start_transmitting (int n_cycles)
  {
      unsigned int port_value;
      for (int i = 0; i < n_cycles; i++)
      {
        port_value = 0;
      do
      {
        PORTB = port_value;
        ASM_INC(port_value);
      }   
      while (port_value < 255);
    }
  }

  void stop_transmitting (int n_cycles)
  {
      unsigned int port_value;
      PORTD = B0000000;
      
      for (int i = 0; i < n_cycles; i++)
      {
        port_value = 0;
      do
      {
        ASM_INC(port_value);
        asm volatile ("NOP");  
      } 
      while (port_value < 255);
    }
  }

I know It needs some perfection, I’m working hardly on it :slight_smile: