Welcome Guest,Register Now
Log In

ANT Forum

Welcome guest, please Login or Register

   

Embedded Asynchronous Mode Help

Rank

Total Posts: 1

Joined 2013-01-04

PM

I am new to the ant platform and I'm having trouble getting any communication working with the Ant board.

i'm using an eval board and have wired up the board to the appropriate pins for asynchronous mode (I've triple checked the pinout).

I have a scope on my TX line to the chip and I can see that I'm sending the appropriately formed packets to the chip. However no matter what I send it never sends me a confirmation on the RTS line (it should toggle on successfully received packet). And I cant get it to send anything out over the RF.

all of the examples on this website are for synchronous mode

I've included my main.c, can anyone see any blatant reasons why nothing seems to work?

/**
 *****************************************************************************
 **
 **  File        : main.c
 **
 **  Abstract    : main function.
 **
 **  Functions   : main
 **
 **  Environment : Atollic TrueSTUDIO(R)
 **                STMicroelectronics STM32F4xx Standard Peripherals Library
 **
 **  Distribution: The file is distributed “as is,” without any warranty
 **                of any kind.
 **
 **  (c)Copyright Atollic AB.
 **  You may use this file as-is or modify it according to the needs of your
 **  project. Distribution of this file (unmodified or modified) is not
 **  permitted. Atollic AB permit registered Atollic TrueSTUDIO(R) users the
 **  rights to distribute the assembled, compiled & linked contents of this
 **  file as part of an application binary file, provided that it is built
 **  using the Atollic TrueSTUDIO(R) toolchain.
 **
 **
 *****************************************************************************
 */

/* Includes ------------------------------------------------------------------*/
#include "stm32f4xx.h"
#include "stm324xg_eval.h"
#include <stdio.h>

/* Private variables */
#define ANT_CH_ID    0x00
#define ANT_CH_TYPE  0x10
#define ANT_NET_ID   0x00
#define ANT_DEV_ID1  0x31
#define ANT_DEV_ID2  0x00
#define ANT_DEV_TYPE 0x01
#define ANT_TX_TYPE  0x01
#define ANT_CH_FREQ  0x0023
#define ANT_CH_PER   0x2000

typedef uint8_t uchar;

uchar txBuffer[32];
uint8_t txBufferSize;
uint8_t txBufferPos;

USART_InitTypeDef USART_InitStructure;
GPIO_InitTypeDef  GPIO_InitStructureA;
GPIO_InitTypeDef  GPIO_InitStructureC;
static 
__IO uint32_t TimingDelay;

/* Private function prototypes -----------------------------------------------*/
void Delay(__IO uint32_t nTime);
void build_Message(ucharmessageuint8_t messageSize);
void Delay(__IO uint32_t nTime);
void TimingDelay_Decrement(void);
void opench();
void closech();
void reset();
void assignch();
void setchid();
void setrf();
void setchperiod();
void sendbroadcast();
void configureGPIO();
void configureUART();


/**
  * @brief  Main program
  * @param  None
  * @retval None
  */
int main(void)
{
   
if (SysTick_Config(SystemCoreClock 1000))
   
{
     
/* Capture error */
     
while (1);
   
}

 configureGPIO
();
 
configureUART();
//  //printf("\n\rherr3o\n\r");
    
Delay(300);
    
//configure the txrx board
    
reset();
    
Delay(150);
    
assignch();
    
Delay(100);
    
setrf();
    
Delay(100);
    
setchperiod();
    
Delay(100);
    
setchid();
    
Delay(100);
    
opench();
    
Delay(100);
    while(
1)
    
{
     sendbroadcast
();
     
Delay(300);
    
}
}


void build_Message
(ucharmessageuint8_t messageSize)
{
 uint8_t i
;
 
int j;
  
// _BIC_SR(GIE);  // disable interrupt

  
txBufferPos  0;          // set position to 0
  
txBufferSize messageSize 3;  // message plus syc, size and checksum
  
txBuffer[0]  0xa4;        // sync byte
  
txBuffer[1]  = (ucharmessageSize 1;  // message size - command size (1)

   
for(i=0i<messageSizei++)
     
txBuffer[2+i] message[i];

  
// calculate the checksum
  
for(i=0i<txBufferSize 1; ++i)
   
txBuffer[txBufferSize 1] txBuffer[txBufferSize 1] txBuffer[i];


   for (
j=0j<txBufferSizej++)
   
{
    
//__io_putchar(*(ptr++));
     //_BIS_SR(GIE);   // enable interrupt
    /* Place your implementation of fputc here */
    /* e.g. write a character to the USART */
    
USART_SendData(EVAL_COM1, (uint8_ttxBuffer[j]);

    
/* Loop until the end of transmission */
    
while (USART_GetFlagStatus(EVAL_COM1USART_FLAG_TC) == RESET)
    
{}
   }
   
//printf("\n\rSent a message!\n\r");
}

/**
  * @brief  Inserts a delay time.
  * @param  nTime: specifies the delay time length, in milliseconds.
  * @retval None
  */
void Delay(__IO uint32_t nTime)
{
  TimingDelay 
nTime;

  while(
TimingDelay != 0);
}

/**
  * @brief  Decrements the TimingDelay variable.
  * @param  None
  * @retval None
  */
void TimingDelay_Decrement(void)
{
  
if (TimingDelay != 0x00)
  
{
    TimingDelay
--;
  
}
}


/*
 * Open channel 1 for communications
 */
void opench()
{
 
//0xA4 SYNC
 //0x01 LENGTH
 //0x4B ID - ANT_OpenChannel
 //0x01  Data - Channel 1
 //0xE8 CRC
 
uchar setup[2];
 
setup[0] 0x4B;
 
setup[1] ANT_CH_ID;
 
build_Message(setup2);
 return;
}

/**
 * Close channel 1 for communications
 */
void closech()
{
 
//0xA4 SYNC
 //0x01 LENGTH
 //0x4C ID - ANT_OpenChannel
 //0x01  Data - Channel 1
 //0xEF CRC
 
uchar setup[2];
 
setup[0] 0x4C;
 
setup[1] ANT_CH_ID;
 
build_Message(setup2);
 return;
}

// Resets module
void reset()
{
 uchar setup[2]
;
 
setup[0] 0x4a// ID Byte
 
setup[1] 0x00// Data Byte N (N=LENGTH)
 
build_Message(setup2);
}

// Assigns CH=0, CH Type=10(TX), Net#=0
void assignch()
{
 uchar setup[4]
;
 
setup[0] 0x42;
 
setup[1] ANT_CH_ID;    // Channel ID, 0x00 for HRM, 0x01 for custom
 
setup[2] ANT_CH_TYPE;  // CH Type
 
setup[3] ANT_NET_ID;   // Network ID
 
build_Message(setup4);
}

// Assigns CH#, Device#=0000, Device Type ID=00, Trans Type=00
void setchid()
{
 uchar setup[6]
;
 
setup[0] 0x51;
 
setup[1] ANT_CH_ID
     
Avatar
RankRankRankRank

Total Posts: 745

Joined 2012-09-14

PM

Hi,

A screenshot or timing diagram of the messages your sending ANT would be useful to help examine what might be going on a little more closely. I've included an example timing diagram of an ANT reset and response message.

Many of the embedded reference designs do include asynchronous and synchronous serial code such as the ANT-FS Embedded Reference Design, the Heart Rate Monitor reference, the Bicycle Power reference, etc, but unfortunately not all of them do at this time.

As a note, your comment here is a little off, the checksum is EF not E8
//0xA4 SYNC
//0x01 LENGTH
//0x4B ID - ANT_OpenChannel
//0x01  Data - Channel 1
//0xE8 CRC 


Are SLEEP and SUSPEND being tied off/controlled appropriately?
If you use the reset pin, ANT will automatically return the Startup Message.
What have you set the BAUD rate to?

Best regards      

Image Attachments

Example_ANT_Reset.png

Click thumbnail to see full-size image