Teensy 3.1 and T2_L4A_8650C DAB / DAB+ / FM module

Status
Not open for further replies.

Rizlagav

New member
Hello new to forum,new to Teensy,s, have played with arduino for a while.
Now i,m more of a hardware man so having some problems with what i think are quite basic concepts.

I,m trying to interface a Teensy3.1 (love having the extra program space for my badly written and blotted code) to a
T2_L4A_8650C DAB / DAB+ / FM module.
The module datasheet ( http://d1jy6p8pks3hof.cloudfront.ne...ct Specification_T2-L4A-8650C__I_20130527.pdf),
programming guide ( http://d1jy6p8pks3hof.cloudfront.net/datasheets/T2L4A/SlavemodeSPEC_eng.pdf),
command set ( http://d1jy6p8pks3hof.cloudfront.net/datasheets/T2L4A/SlaveModeCommandSet 3.1.1.xls).

The module recieves commands on a Uart in RS232 protocol.From programming guide

"Before master device start sending command to slave device, the master should
query the slave device status to see if slave is in proper state to receive command.
Master can query the slave status through system command GetSysRdy. Slave
replies ACK if it is ready to get command or NAK if not"

Now i,ve made a board and all power and grounds are connected, put serial2 connected to Uart with 10k pullups.
Now i think its my code, haven't grasped sending bytes as (0x00).
Need basic help

Code:
#include <Bounce.h>





  
#define BUTTON1 14
#define BUTTON2 15
#define BUTTON3 16
#define BUTTON4 17

const int ledPin = 13;
  
 // Instantiate a Bounce object with a 5 millisecond debounce time
Bounce bouncer1 = Bounce( BUTTON1,10 );
Bounce bouncer2 = Bounce( BUTTON2,10 );
Bounce bouncer3 = Bounce( BUTTON3,10 );
Bounce bouncer4 = Bounce( BUTTON4,10); 




void setup() {

  pinMode(ledPin, OUTPUT);
  
  digitalWrite(ledPin, HIGH);
  delay (1000);
  digitalWrite(ledPin, LOW);
  	Serial.begin(9600);
        Serial2.begin(19200);
  
  pinMode(14, INPUT_PULLUP);
  pinMode(15, INPUT_PULLUP);
  pinMode(16, INPUT_PULLUP);
  pinMode(17, INPUT_PULLUP);
  
  
}

void loop() {
 // Update the debouncer
  bouncer1.update ( );
  bouncer2.update ( );
  bouncer3.update ( );
  bouncer4.update ( );
 
 int incomingByte;
 
 // Get the update value
 int value1 = bouncer1.read();
 int value2 = bouncer2.read();
 int value3 = bouncer3.read();
 int value4 = bouncer4.read();
 
 
 // Turn on or off the LED
 if ( value1 == LOW) {SYSTEMGetSysRdy();} 
 
 if ( value2 == LOW) {SYSTEMReset();} 
 
 if ( value3 == LOW) {STREAM_Search();} 
 
 if ( value4 == LOW) {SYSTEM_GetAllVersion();} 
 if (Serial2.available() > 0) {
		incomingByte = Serial2.read();
                 
		Serial.print("Serial2 received: ");
		Serial.write(incomingByte);
                //Serial1.print("Serial1 received:");
                //Serial1.write(incomingByte);
                
                delay (1000);
	}
 
 
}
  
//returntype functionName( arguments ){
void SYSTEMGetSysRdy(){

  //function body
  //Step 1 - SYSTEMGetSysRdy - Serial2 OUT: FE 00 00 01 00 FD - Serial2 IN:?
   
   Serial.print("SYSTEMGetSysRdy: ");
   
        Serial2.write(0xFE);
        //        Serial2.write(254, BYTE);
        Serial2.write(0x00);
        Serial2.write(0x00);
        Serial2.write(0x01);
        Serial2.write(0x00);
        Serial2.write(0xFD);
        delay (100);
        Serial.print("SYSTEMGetSysRdy: ");
        Serial.print("Button 1: ");
  //return returntype;
  //implied by closing curly bracked
}


//returntype functionName( arguments ){
void SYSTEMReset(){

  //function body
   Serial.print("SYSTEMReset: ");
   
   //Step 0 - SYSTEMReset - Serial2 OUT: FE 00 01 01 00 FD - Serial2 IN:?
        Serial2.write(0xFE);
        Serial2.write(0x00);
        Serial2.write(0x01);
        Serial2.write(0x01);
        Serial2.write(0x00);
        Serial2.write(0xFD);
        delay (100);
        Serial.print("SYSTEMReset: ");
        Serial.print("Button 2: ");
        
  //return returntype;
  //implied by closing curly bracked
}

//returntype functionName( arguments ){
void STREAM_Search(){

  //function body
     Serial.print("STREAM_Search: ");
   
   //Step 2 - STREAM_Search - UART OUT: FE 01 03 01 02 (Start frequency index [1]) (End frequency index [1]) FD - UART IN:?
        
        Serial2.write(0xFE);
        Serial2.write(0x01);
        Serial2.write(0x03);
        Serial2.write(0x01);
        Serial2.write(0x02);
        Serial2.write(0x01);
        Serial2.write(0x09);
        Serial2.write(0xFD);
        delay (100);
        Serial.print("STREAM_Search: ");
        Serial.print("Button 3: ");
        
  //return returntype;
  //implied by closing curly bracked
}

//returntype functionName( arguments ){
void SYSTEM_GetAllVersion(){

  //function body
   
   Serial.print("SYSTEM_GetAllVersion: ");
   
   //Step 0 - SYSTEM_GetAllVersion - Serial2 OUT: FE 00 01 01 00 FD - Serial2 IN:?
        Serial2.write(0xFE);
        Serial2.write(0x00);
        Serial2.write(0x01);
        Serial2.write(0x01);
        Serial2.write(0x00);
        Serial2.write(0xFD);
        delay (100);
        Serial.print("SYSTEM_GetAllVersion: ");
        Serial.print("Button 4: ");
        
  //return returntype;
  //implied by closing curly bracked
}

So not trying to do much a the moment, only get it to talk back.Still dont grasp recieving ack or nack.
Any guidance appreciated.
Thanks Gav
 
Status
Not open for further replies.
Back
Top