Jump to content
43oh

Serial port on CC3200-LAUNCHXL different from TM4C123GXL?


Recommended Posts

I'm trying to make a WiFi DMX webserver/transmitter.

 

I have following code working on my TM4C123GXL.

/*

*/

// most launchpads have a red LED
#define LED RED_LED
#include "inc/hw_uart.h"
#include <stdint.h>
#include "driverlib\uart.h"

//see pins_energia.h for more LED definitions

  #define DMX_MAX 128 // max. number of DMX data packages.
  
const int buttonPin = PUSH2; 
int buttonState;             // the current reading from the input pin
int lastButtonState = LOW;   // the previous reading from the input pin
const int ledPin =  GREEN_LED;
uint8_t DMXBuffer[DMX_MAX];
// the setup routine runs once when you press reset:

long lastDebounceTime = 0;  // the last time the output pin was toggled
long debounceDelay = 50;    // the debounce time; increase if the output flickers

void DMXstart()
{
  // DMX is a 250000 baud serial data
  //Serial1.begin(250000, (UART_CONFIG_PAR_NONE | UART_CONFIG_STOP_TWO |UART_CONFIG_WLEN_8));
  // initialize the DMX buffer
  for (int n = 0; n < DMX_MAX; n++)
    DMXBuffer[n] = 20;
 
} // DMXstart
 
 
void DMXwrite(int channel, uint8_t value)
{
  // press parameters to allowed range
  if (channel < 1) channel = 1;
  if (channel > DMX_MAX) channel = DMX_MAX;
  if (value < 0)   value = 0;
  if (value > 255) value = 255;
  // store value for later sending
  DMXBuffer[channel-1] = value;
} // DMXwrite
 
 
void DMXflush()
{
  // send the break by sending a slow 0 byte
  Serial1.begin(112500,(UART_CONFIG_PAR_NONE | UART_CONFIG_STOP_TWO |UART_CONFIG_WLEN_8));
  Serial1.write((uint8_t)0);
  // now back to DMX speed: 250000baud
  Serial1.begin(250000,(UART_CONFIG_PAR_NONE | UART_CONFIG_STOP_TWO |UART_CONFIG_WLEN_8));
  // write start code
  Serial1.write((uint8_t)0);
  // write all the values from the array
  Serial1.write(DMXBuffer, sizeof(DMXBuffer));
} // DMXflush
int cn = 0;
void setup() {     
//Serial1.begin(250000,(UART_CONFIG_PAR_NONE | UART_CONFIG_STOP_TWO |	UART_CONFIG_WLEN_8)); 
 // Serial1.write(5);
   pinMode(buttonPin, INPUT_PULLUP);
  pinMode(LED, OUTPUT);
    pinMode(ledPin, OUTPUT);
  
  digitalWrite(ledPin, LOW); 
  digitalWrite(LED, LOW);
  DMXstart();
}

// the loop routine runs over and over again forever:
void loop() {
  int reading = digitalRead(buttonPin);
  if (reading != lastButtonState) {
    lastDebounceTime = millis();
  } 
  if ((millis() - lastDebounceTime) > debounceDelay) {
    buttonState = reading;
  }
  
  // set the LED using the state of the button:
  //digitalWrite(LED, buttonState);
  if (buttonState ==LOW) {
    digitalWrite(ledPin, HIGH);   // turn the LED on (HIGH is the voltage level)
    delay(10);               // wait for a second7
    cn+=1;
    DMXwrite(1,cn);
    DMXwrite(2,cn);
    DMXwrite(3,cn);
    DMXflush();
    delay(10);
//    Serial1.write(99);
//    Serial1.write(4);
//    Serial1.write(3);
//    Serial1.write(2);
//    Serial1.println(1);
//    
    buttonState = HIGH;
    
    digitalWrite(ledPin, LOW); 
  }

  // save the reading.  Next time through the loop,
  // it'll be the lastButtonState:
  lastButtonState = reading;
 
}

I use similar code on a CC32000-LaunchXL but I can't get it to work.

 

The DMX client is an attiny2313. the 2313 works perfectly when controlled from an ENTTEC opendmx controller. And it works when using the 123GXL.

 

I'm able to communicate between my CC3200 and the 123GXL, so I see the DMX packet arrive when I hook both of en boards together

 

But the problem is the DMX protocol relies on a framing error

These lines

// send the break by sending a slow 0 byte
  Serial1.begin(112500,(UART_CONFIG_PAR_NONE | UART_CONFIG_STOP_TWO |UART_CONFIG_WLEN_8));
  Serial1.write((uint8_t)0);
  // now back to DMX speed: 250000baud
  Serial1.begin(250000,(UART_CONFIG_PAR_NONE | UART_CONFIG_STOP_TWO |	UART_CONFIG_WLEN_8));

generate a framing error on the DMX client. That way the client knows a new packet is incoming.

It works on the 123GXL. But not on the CC3200.

 

I've put code in the framing error part on the DMX client, and the framing error is never received..

So when I put a LEDflash in the RX interupt on the DMX client, I see it flash, so data is received.

When I put the LEDflash in the framing error if-block, it doesn't flash.

The framing error is received when I use the 123GXL to transmit.

 

So why does the same code on CC3200 and 123GXL result in different effect on the client?

 

 

Oh and 1 small thing, I've change the Serial.begin in hardwareSerial.cpp so I can use 2 stop bits.

void HardwareSerial::begin(unsigned long baud,unsigned long mask)


----
MAP_UARTConfigSetExpClk(UART_BASE, 80000000, baudRate,mask);
Link to post
Share on other sites

8 hours of searching for a solution with no progress, 

Finnaly I give up and post on this forum for help

And 2 hours later I'm in the shower and think "it's a timing problem!"

So I added a delay after the first 0 and it works...

  Serial1.begin(115200,(UART_CONFIG_PAR_NONE | UART_CONFIG_STOP_TWO |UART_CONFIG_WLEN_8));
  Serial1.write((uint8_t)0);
 delay(1);
 
  // now back to DMX speed: 250000baud
  Serial1.begin(250000,(UART_CONFIG_PAR_NONE | UART_CONFIG_STOP_TWO |	UART_CONFIG_WLEN_8));

Weird how the 123GXL doesn't need the delay...

Link to post
Share on other sites

I do know the CC3200 peripherals are different from the TM4C123's.  I personally liked the TM4C123 peripherals.  CC3200 peripherals suck, and the MSP432 just uses a jacked version of the old MSP430 peripherals which suck compared to the TM4C123's too.

 

Luckily, the newer SimpleLink CC26xx (BLE/2.4GHz 802.15.4 ZigBee-et-al type of crap) and CC13xx (sub-1GHz) ARM chipsets appear to borrow the TM4C123 peripherals from what I can tell... (and throw power consumption metrics down even further than the MSP432).

They also have a digital I/O switch matrix that lets you route any peripheral's function to any of the GPIO's which is sweet.

(</end TI marketing schpiel since I don't actually work for TI>)

 

Of course none of this helps you with WiFi...

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...