mathertel / DMXSerial

An Arduino library for sending and receiving DMX packets.
BSD 3-Clause "New" or "Revised" License
320 stars 76 forks source link

Adding definition for RXCn for Atmega 8 #63

Closed XPModder closed 1 year ago

XPModder commented 2 years ago

Added the required definition for RXCn for the Atmega 8 as it was missing, which caused a compilation error. This change solves the error.

mathertel commented 1 year ago

I added the ATMega 8 definitions in 2013 for experimental purpose. Please report successful implementation as I have no project based on this chip.

kokospalme commented 1 year ago

Thank you for adding ATMega 8 support! But unfortunately I have no luck with my circuit. I have a Receiver with an SN75176 together with a 6N137 optocoupler (like your circuit on your website). When I connect the output (optocoupler 6N137 pin6 with pullup to 5V) to PD0(UART RX) on the ATMega8, I get no Data (red LED on, green LED is off). When I connect the optocoupler's output to an Arduino Uno's RX pin (Pin 0), the Uno does work fine with the same code. I already built 2 circuits/PCBs with the same result.

pinout ATMega8

This is my code:

#include <DMXSerial.h>
#include <Wire.h>

#define LED_RED 7 //red LED on PD7/7
#define LED_GREEN 8 //green LED PB0/8
#define DMX_CHANNEL 1 //dmx test-channel

void requestEvent();  //event handler for I2C communication

void setup() {
  pinMode(LED_RED, OUTPUT);
  pinMode(LED_GREEN, OUTPUT);

  DMXSerial.init(DMXReceiver);
  Wire.begin(8);                // join i2c bus with address #8
  Wire.onRequest(requestEvent); // register event

}

void loop() {
  if(DMXSerial.read(DMX_CHANNEL) > 100){  //alternate LEDs (no pwm on these pins)
    digitalWrite(LED_GREEN, HIGH);
    digitalWrite(LED_RED, LOW);
  }else{
    digitalWrite(LED_GREEN, LOW);
    digitalWrite(LED_RED, HIGH);
  }

}

  void requestEvent() {
    Wire.write(DMXSerial.read(DMX_CHANNEL)); // respond with message of 1 byte
  }