本帖最后由 littleshrimp 于 2015-5-19 19:20 编辑
Lpc54102 ODFM/FDM解码
为了配合LPC54102的FDM解码使用LPC1549生成数据,通过DAC发送 因为LPC1549没有FPU做IFFT运算比较慢,我使用查表的方式输出数据。 DAC的最大输出频率为500 kSamples/s, 新键一个数组,DAC的点数为64 //7.8125KHz
-
uint16_t fqs[9][64] ={
-
{2248,2446,2641,2831,3012,3185,3346,3495,3630,3749,3853,3939,4006,4055,4085,4095,4085,4055,4006,3939,3853,3749,3630,3495,3346,3185,3012,2831,2641,2446,2248,2047,1846,1648,1453,1263,1082,909,748,599,464,345,241,155,88,39,9,0,9,39,88,55,241,345,464,599,748,909,1082,1263,1453,1648,1846,2047},
-
{2446,2831,3185,3495,3749,3939,4055,4095,4055,3939,3749,3495,3185,2831,2446,2047,1648,1263,909,599,345,155,39,0,39,155,345,599,909,1263,1648,2047,2446,2831,3185,3495,3749,3939,4055,4095,4055,3939,3749,3495,3185,2831,2446,2047,1648,1263,909,599,345,155,39,0,39,155,345,599,909,1263,1648,2047},
-
{2641,3185,3630,3939,4085,4055,3853,3495,3012,2446,1846,1263,748,345,88,0,88,345,748,1263,1846,2446,3012,3495,3853,4055,4085,3939,3630,3185,2641,2047,1453,909,464,155,9,39,241,599,1082,1648,2248,2831,3346,3749,4006,4095,4006,3749,3346,2831,2248,1648,1082,599,241,39,9,155,464,909,1453,2047},
-
{2831,3495,3939,4095,3939,3495,2831,2047,1263,599,155,0,155,599,1263,2047,2831,3495,3939,4095,3939,3495,2831,2047,1263,599,155,0,155,599,1263,2047,2831,3495,3939,4095,3939,3495,2831,2047,1263,599,155,0,155,599,1263,2047,2831,3495,3939,4095,3939,3495,2831,2047,1263,599,155,0,155,599,1263,2047},
-
{3012,3749,4085,3939,3346,2446,1453,599,88,39,464,1263,2248,3185,3853,4095,3853,3185,2248,1263,464,39,88,599,1453,2446,3346,3939,4085,3749,3012,2047,1082,345,9,155,748,1648,2641,3495,4006,4055,3630,2831,1846,909,241,0,241,909,1846,2831,3630,4055,4006,3495,2641,1648,748,155,9,345,1082,2047},
-
{3185,3939,4055,3495,2446,1263,345,0,345,1263,2446,3495,4055,3939,3185,2047,909,155,39,599,1648,2831,3749,4095,3749,2831,1648,599,39,155,909,2047,3185,3939,4055,3495,2446,1263,345,0,345,1263,2446,3495,4055,3939,3185,2047,909,155,39,599,1648,2831,3749,4095,3749,2831,1648,599,39,155,909,2047},
-
{3346,4055,3853,2831,1453,345,9,599,1846,3185,4006,3939,3012,1648,464,0,464,1648,3012,3939,4006,3185,1846,599,9,345,1453,2831,3853,4055,3346,2047,748,39,241,1263,2641,3749,4085,3495,2248,909,88,155,1082,2446,3630,4095,3630,2446,1082,155,88,909,2248,3495,4085,3749,2641,1263,241,39,748,2047},
-
{3495,4095,3495,2047,599,0,599,2047,3495,4095,3495,2047,599,0,599,2047,3495,4095,3495,2047,599,0,599,2047,3495,4095,3495,2047,599,0,599,2047,3495,4095,3495,2047,599,0,599,2047,3495,4095,3495,2047,599,0,599,2047,3495,4095,3495,2047,599,0,599,2047,3495,4095,3495,2047,599,0,599,2047},
-
{3630,4055,3012,1263,88,345,1846,3495,4085,3185,1453,155,241,1648,3346,4095,3346,1648,241,155,1453,3185,4085,3495,1846,345,88,1263,3012,4055,3630,2047,464,39,1082,2831,4006,3749,2248,599,9,909,2641,3939,3853,2446,748,0,748,2446,3853,3939,2641,909,9,599,2248,3749,4006,2831,1082,39,464,2047}
-
};
复制代码对应的频率为 7.8125KHz~70.3125KHz共9组数组 1*500KHz /64Point = 7.8125KHz 8*500KHz/64Point = 62.5KHz 9*500KHz /64Point = 70.3125KHz 将要发送的一个字节数据拆分成8个位,每位对应一个频率,数据为0时DAC输出7.8125KHz第0位为1时输出7.8125KHz + 7.8125*2KHz,以此类推。 在DAC中断里输出数据 void DAC_IRQHandler(void)
-
{
-
if
- (Chip_DAC_GetIntStatus(LPC_DAC))
-
{
-
if(!dacClear)
-
{
-
// dacOutValue
- = 0;
-
dacOutValue
- = fqs[0][fqsIndex];
-
dacOutValue
- += ((dacOutData & BIT0) == BIT0) ? fqs[1][fqsIndex] : 0;
-
dacOutValue
- += ((dacOutData & BIT1) == BIT1) ? fqs[2][fqsIndex] : 0;
-
dacOutValue
- += ((dacOutData & BIT2) == BIT2) ? fqs[3][fqsIndex] : 0;
-
dacOutValue
- += ((dacOutData & BIT3) == BIT3) ? fqs[4][fqsIndex] : 0;
-
dacOutValue
- += ((dacOutData & BIT4) == BIT4) ? fqs[5][fqsIndex] : 0;
-
dacOutValue
- += ((dacOutData & BIT5) == BIT5) ? fqs[6][fqsIndex] : 0;
-
dacOutValue
- += ((dacOutData & BIT6) == BIT6) ? fqs[7][fqsIndex] : 0;
-
dacOutValue
- += ((dacOutData & BIT7) == BIT7) ? fqs[8][fqsIndex] : 0;
-
dacOutValue
- /= (numbits_lookup_table[dacOutData]+1);
-
Chip_DAC_UpdateValue(LPC_DAC,
- dacOutValue);
-
fqsIndex++;
-
if(fqsIndex
- >= length)
-
{
-
fqsIndex
- = 0;
-
}
-
}
-
else
-
{
-
fqsIndex
- = 0;
-
//输出低电平
-
Chip_DAC_UpdateValue(LPC_DAC,
- 0);
-
}
-
}
-
}
复制代码
完成DAC FDM编码后开始写LPC54102 FDM解码程序 为了实现精准采样采用SystemTick定时器给ADC发送开始采样信号 void SysTick_Handler(void)
-
{
-
am_led_toggle(0);
-
/*
启动AD转换 */
-
am_adc_start(g_adc0_handle,
- AMHW_ADC0_CHAN_3);
-
}
复制代码采集到的数据保存到临时数据,LPC1549输出数据间使用低电平间隔,当LPC54102检测到低电平数大于指定值时向前提取64点有效数据进行FFT转换,判断对应频率下的模值分析LPC1549发送来的数据。 下边是LPC1549发送数据、波形和LPC54102 FFT后对应频率下的模值
0xff 15.png 0xdf 16.png 0x55 17.png 0x0f 18.png 0xf0 20.png
源文件 LPC1549使用lpcopen_2_08c_keil_iar_nxp_lpcxpresso_1549例程修改 LPC54102使用周立功ametal_easy_arm_lpc5410x_v1.00例程修改
问题: LPC1549发送单一数据时LPC54102可以正常解码,如果让LPC1549全速跑起来LPC54102会丢掉一些字符。 一方面是LPC54102做FFT的速度还不够快,另一方面上边的例程是根据自己的理解和想法编写的在算法上肯定也有问题 有时间好好研究一下OFDM原理,弄明白后再写一个像样的程序。
|