Changeset - 9becfc2d0fd1
[Not reviewed]
default
0 1 0
Ethan Zonca - 10 years ago 2016-03-06 22:20:20
ez@ethanzonca.com
Correctly tune WSPR transmission frequencies
1 file changed with 9 insertions and 22 deletions:
0 comments (0 inline, 0 general)
src/main.c
Show inline comments
 
#include "stm32f0xx_hal.h"
 
#include "si5351.h"
 
#include "jtencode.h"
 
#include "adc.h"
 
#include "dma.h"
 
#include "i2c.h"
 
#include "usart.h"
 
#include "gpio.h"
 
#include "gps.h"
 
 
 
void sysclk_init(void);
 
 
#define WSPR_DEFAULT_FREQ 14097100UL
 
 
char call[7] = "N0CALL";
 
char loc[5] = "AA00";
 
uint8_t dbm = 27;
 
uint8_t tx_buffer[255];
 
 
int main(void)
 
{
 
    HAL_Init();
 
 
    sysclk_init();
 
    gpio_init();
 
    //led_blink(5);
 
    MX_DMA_Init();
 
    MX_ADC_Init();
 
    i2c_init();
 
 
    HAL_GPIO_WritePin(OSC_NOTEN, 0);
 
    HAL_GPIO_WritePin(TCXO_EN, 1);
 
    HAL_Delay(100);
 
 
//    MX_USART1_UART_Init();
 
 
    //jtencode_init();
 
    jtencode_init();
 
    //gps_init();
 
    si5351_init(i2c_get(), SI5351_CRYSTAL_LOAD_8PF, 0);
 
    si5351_set_correction(0);
 
 
    //SI5351_XTAL_FREQ
 
    si5351_set_pll(SI5351_PLL_FIXED, SI5351_PLLA);
 
 
 
    si5351_set_ms_source(SI5351_CLK0, SI5351_PLLA);
 
    si5351_set_ms_source(SI5351_CLK1, SI5351_PLLA);
 
    si5351_set_ms_source(SI5351_CLK2, SI5351_PLLA);
 
    si5351_set_ms_source(SI5351_CLK3, SI5351_PLLA);
 
    //si5351_set_pll(SI5351_PLL_FIXED, SI5351_PLLA);
 
    //si5351_set_ms_source(SI5351_CLK0, SI5351_PLLA);
 
    si5351_set_freq(WSPR_DEFAULT_FREQ * 100, 0, SI5351_CLK0);
 
    si5351_drive_strength(SI5351_CLK0, SI5351_DRIVE_2MA); // Set for max power if desired (8ma max)
 
    si5351_output_enable(SI5351_CLK0, 1);
 
    //si5351_pll_reset(SI5351_PLLA);
 
 
    si5351_set_freq(1000000UL * 100, SI5351_PLL_FIXED, SI5351_CLK0);
 
 
    si5351_drive_strength(SI5351_CLK0, SI5351_DRIVE_2MA); // Set for max power if desired (8ma max)
 
 
 
    si5351_output_enable(SI5351_CLK0, 1); // Disable the clock initially
 
 
    //wspr_encode(call, loc, dbm, tx_buffer);
 
 
    si5351_pll_reset(SI5351_PLLA);
 
    wspr_encode(call, loc, dbm, tx_buffer);
 
 
    HAL_Delay(1000);
 
 
    uint32_t led_timer = HAL_GetTick();
 
    uint32_t last_gps  = HAL_GetTick();
 
 
    while (1)
 
    {
 
        if(HAL_GetTick() - led_timer > 100)
 
        {
 
            HAL_GPIO_TogglePin(LED_BLUE);
 
            led_timer = HAL_GetTick();
 
        }
 
        if(HAL_GetTick() - last_gps > 100)
 
        {
 
//            gps_process();
 
            last_gps = HAL_GetTick();
 
        }
 
    }
 
}
 
 
 
// Initialize system clocks
 
void sysclk_init(void)
0 comments (0 inline, 0 general)