/var/www/restricted/ssh/stm32/www/stm32circle/ STM CircleOS forum / generating 1V signal onto connector pin

Username:     
Password:     
             

Forum

# 1   2012-01-22 17:52:30 generating 1V signal onto connector pin

erazor667
New member
Registered: 2011-11-27
Posts: 7

generating 1V signal onto connector pin

I'm trying to generate a simple analog output signal. I'm checking pin number 4 (and other pins) on the connector but I can't find 1V anywhere. What I'm doing wrong? Please help, I've tried also the examples from STDIO library, with no success.

This is my code:

/* Includes ------------------------------------------------------------------*/
#include "circle_api.h"
#include "stm32f10x.h"
#include "stm32f10x_type.h"
#include "stm32f10x_dac.h"
#include "stm32f10x_gpio.h"
#include "stm32f10x_rcc.h"
#define __STM32F10x_H

/* Private defines -----------------------------------------------------------*/

// The following should be the minimal CircleOS version needed by your application
#define NEEDEDVERSION "V 3.7"

/* Private functions ---------------------------------------------------------*/
static enum MENU_code MsgVersion(void);

/* Public variables ----------------------------------------------------------*/
const char Application_Name[8+1] = {"dac"};      // Max 8 characters

uint16_t Sal;

/*******************************************************************************
* Function Name  : Application_Ini
* Description    : Initialization function of Circle_App. This function will
*                  be called only once by CircleOS.
* Input          : None
* Return         : MENU_CONTINUE_COMMAND
*******************************************************************************/
enum MENU_code Application_Ini(void)
    {
    // Ensure that the current OS version is recent enough
    if(strcmp(UTIL_GetVersion(), NEEDEDVERSION) < 0)
        {
        return MsgVersion();       }
   
    RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);
    RCC_APB1PeriphClockCmd(RCC_APB1Periph_DAC, ENABLE);
   
   
    GPIO_InitTypeDef GPIO_InitStructure;
    GPIO_InitStructure.GPIO_Pin =  GPIO_Pin_4;
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_OD;
    GPIO_Init(GPIOA, &GPIO_InitStructure);   
   

    return MENU_CONTINUE_COMMAND;
    }

/*******************************************************************************
* Function Name  : Application_Handler
* Description    : Management of the Circle_App.
*
* Input          : None
* Return         : MENU_CONTINUE
*******************************************************************************/
enum MENU_code Application_Handler(void)
    {


    DAC_DeInit();
   
    DAC_InitTypeDef DAC_InitStructure;
   
    DAC_InitStructure.DAC_Trigger = DAC_Trigger_None;
    DAC_InitStructure.DAC_WaveGeneration = DAC_WaveGeneration_None;
    DAC_InitStructure.DAC_LFSRUnmask_TriangleAmplitude = DAC_LFSRUnmask_Bits11_0;
    DAC_InitStructure.DAC_OutputBuffer = DAC_OutputBuffer_Enable;
   
    DAC_Init(DAC_Channel_1, &DAC_InitStructure);   
   
    DAC_Cmd(DAC_Channel_1, ENABLE);

    DAC_SetChannel1Data(DAC_Align_12b_R, 0x0500);
   

   
#if 1
    // If the button is pressed, the application is exited
    if(BUTTON_GetState() == BUTTON_PUSHED)
        {
        BUTTON_WaitForRelease();
        return MENU_Quit();
        }
#endif

    return MENU_CONTINUE;   // Returning MENU_LEAVE will quit to CircleOS
    }

/*******************************************************************************
* Function Name  : MsgVersion
* Description    : Display the current CircleOS version and the version needed
*                  exit to main menu after 4 secondes
*
* Input          : None
* Return         : MENU_REFRESH
*******************************************************************************/
static enum MENU_code MsgVersion(void)
   {
   int hh,mm,ss,ss2;
   
   DRAW_DisplayString(5,60,"CircleOS",17);
   DRAW_DisplayString(80,60,UTIL_GetVersion(),6);
   DRAW_DisplayString(5,34,NEEDEDVERSION,6);
   DRAW_DisplayString(50,34," required",12);
   
   RTC_GetTime( &hh, &mm, &ss);
   ss = ss + 4;                  // 4 secondes
   ss = ss%60;
   
   do
        {
        RTC_GetTime( &hh, &mm, &ss2 );
        }
   while ( ss2 != ss );           // do while < 4 secondes
   
   DRAW_Clear();
   return MENU_REFRESH;
   }

Offline

 

# 2   2012-01-25 07:39:56 generating 1V signal onto connector pin

yrt
Administrator
From: Grenoble-France
Registered: 2008-06-11
Posts: 520
Website

Re: generating 1V signal onto connector pin

Which version of Primer do you use ? Because the pinout can be different.
If you use PA4 (DAC_OUT1) on Primer2, the signal will be available on pin 17 of the extension connector.

Offline

 

# 3   2012-01-28 08:16:49 generating 1V signal onto connector pin

erazor667
New member
Registered: 2011-11-27
Posts: 7

Re: generating 1V signal onto connector pin

You're right, before You replied me I've checked the manual and the signal is on pin number 17 (I'm using primer 2).

But I have another question, when I set hex value 0x0294 which corresponds to 0,5V on output, on the pin I get 0,468V which is not good enough.
Below there are more examples:

hex             output[V]      pin17[V]
0x07bd        1,5               1,39
0x0500        0,97             0,905
0x00            0                 0,056

What can I do to make it more precise?

Offline

 

# 4   2012-02-01 12:44:02 generating 1V signal onto connector pin

yrt
Administrator
From: Grenoble-France
Registered: 2008-06-11
Posts: 520
Website

Re: generating 1V signal onto connector pin

How do you calculate the voltage you are expecting ?

Offline

 

Board footer