This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

IQMath sin table has 512 values or 1024 values??

Hi Guys,

I am using TMS32F28027 MCU. I wrote a simple code to test the sin table and then printed its values to a text file using Breakpoint method. Actually I am calling till 512, but the text file has 1024 values. I have attached the text file with this post.

My questions:

Array size of sin table, is it 512 or 1024?

Even if it has 1024 values, why is it saving all 1024 values to the text file? Because I am calling till 512 only(pls see CODE below).

The first three values stored in the text file are always garbage value(pls see text file), how to overcome this?

CODE:

void main(void)
{
   int  y = 0;   _iq x = _IQ(0);
    for(y = 0; y<512; y++){
        x = _IQ30toIQ(IQsinTable[y]);
    }
}

1651 3 8806 1 2 0
34020
34020
0
0
402
402
804
804
1206
1206
1607
1607
2009
2009
2410
2410
2811
2811
3211
3211
3611
3611
4011
4011
4409
4409
4808
4808
5205
5205
5602
5602
5997
5997
6392
6392
6786
6786
7179
7179
7571
7571
7961
7961
8351
8351
8739
8739
9126
9126
9512
9512
9896
9896
10278
10278
10659
10659
11039
11039
11416
11416
11793
11793
12167
12167
12539
12539
12910
12910
13278
13278
13645
13645
14010
14010
14372
14372
14732
14732
15090
15090
15446
15446
15800
15800
16151
16151
16499
16499
16846
16846
17189
17189
17530
17530
17869
17869
18204
18204
18537
18537
18868
18868
19195
19195
19519
19519
19841
19841
20159
20159
20475
20475
20787
20787
21097
21097
21403
21403
21706
21706
22005
22005
22301
22301
22594
22594
22884
22884
23170
23170
23453
23453
23732
23732
24007
24007
24279
24279
24547
24547
24812
24812
25073
25073
25330
25330
25583
25583
25832
25832
26077
26077
26319
26319
26557
26557
26790
26790
27020
27020
27245
27245
27466
27466
27684
27684
27897
27897
28106
28106
28310
28310
28511
28511
28707
28707
28898
28898
29086
29086
29269
29269
29447
29447
29621
29621
29791
29791
29956
29956
30117
30117
30273
30273
30425
30425
30572
30572
30714
30714
30852
30852
30985
30985
31114
31114
31237
31237
31357
31357
31471
31471
31581
31581
31685
31685
31785
31785
31881
31881
31971
31971
32057
32057
32138
32138
32214
32214
32285
32285
32351
32351
32413
32413
32469
32469
32521
32521
32568
32568
32610
32610
32647
32647
32679
32679
32706
32706
32728
32728
32745
32745
32758
32758
32765
32765
32768
32768
32765
32765
32758
32758
32745
32745
32728
32728
32706
32706
32679
32679
32647
32647
32610
32610
32568
32568
32521
32521
32469
32469
32413
32413
32351
32351
32285
32285
32214
32214
32138
32138
32057
32057
31971
31971
31881
31881
31785
31785
31685
31685
31581
31581
31471
31471
31357
31357
31237
31237
31114
31114
30985
30985
30852
30852
30714
30714
30572
30572
30425
30425
30273
30273
30117
30117
29956
29956
29791
29791
29621
29621
29447
29447
29269
29269
29086
29086
28898
28898
28707
28707
28511
28511
28310
28310
28106
28106
27897
27897
27684
27684
27466
27466
27245
27245
27020
27020
26790
26790
26557
26557
26319
26319
26077
26077
25832
25832
25583
25583
25330
25330
25073
25073
24812
24812
24547
24547
24279
24279
24007
24007
23732
23732
23453
23453
23170
23170
22884
22884
22594
22594
22301
22301
22005
22005
21706
21706
21403
21403
21097
21097
20787
20787
20475
20475
20159
20159
19841
19841
19519
19519
19195
19195
18868
18868
18537
18537
18204
18204
17869
17869
17530
17530
17189
17189
16846
16846
16499
16499
16151
16151
15800
15800
15446
15446
15090
15090
14732
14732
14372
14372
14010
14010
13645
13645
13278
13278
12910
12910
12539
12539
12167
12167
11793
11793
11416
11416
11039
11039
10659
10659
10278
10278
9896
9896
9512
9512
9126
9126
8739
8739
8351
8351
7961
7961
7571
7571
7179
7179
6786
6786
6392
6392
5997
5997
5602
5602
5205
5205
4808
4808
4409
4409
4011
4011
3611
3611
3211
3211
2811
2811
2410
2410
2009
2009
1607
1607
1206
1206
804
804
402
402
0
0
-403
-403
-805
-805
-1207
-1207
-1608
-1608
-2010
-2010
-2411
-2411
-2812
-2812
-3212
-3212
-3612
-3612
-4012
-4012
-4410
-4410
-4809
-4809
-5206
-5206
-5603
-5603
-5998
-5998
-6393
-6393
-6787
-6787
-7180
-7180
-7572
-7572
-7962
-7962
-8352
-8352
-8740
-8740
-9127
-9127
-9513
-9513
-9897
-9897
-10279
-10279
-10660
-10660
-11040
-11040
-11417
-11417
-11794
-11794
-12168
-12168
-12540
-12540
-12911
-12911
-13279
-13279
-13646
-13646
-14011
-14011
-14373
-14373
-14733
-14733
-15091
-15091
-15447
-15447
-15801
-15801
-16152
-16152
-16500
-16500
-16847
-16847
-17190
-17190
-17531
-17531
-17870
-17870
-18205
-18205
-18538
-18538
-18869
-18869
-19196
-19196
-19520
-19520
-19842
-19842
-20160
-20160
-20476
-20476
-20788
-20788
-21098
-21098
-21404
-21404
-21707
-21707
-22006
-22006
-22302
-22302
-22595
-22595
-22885
-22885
-23171
-23171
-23454
-23454
-23733
-23733
-24008
-24008
-24280
-24280
-24548
-24548
-24813
-24813
-25074
-25074
-25331
-25331
-25584
-25584
-25833
-25833
-26078
-26078
-26320
-26320
-26558
-26558
-26791
-26791
-27021
-27021
-27246
-27246
-27467
-27467
-27685
-27685
-27898
-27898
-28107
-28107
-28311
-28311
-28512
-28512
-28708
-28708
-28899
-28899
-29087
-29087
-29270
-29270
-29448
-29448
-29622
-29622
-29792
-29792
-29957
-29957
-30118
-30118
-30274
-30274
-30426
-30426
-30573
-30573
-30715
-30715
-30853
-30853
-30986
-30986
-31115
-31115
-31238
-31238
-31358
-31358
-31472
-31472
-31582
-31582
-31686
-31686
-31786
-31786
-31882
-31882
-31972
-31972
-32058
-32058
-32139
-32139
-32215
-32215
-32286
-32286
-32352
-32352
-32414
-32414
-32470
-32470
-32522
-32522
-32569
-32569
-32611
-32611
-32648
-32648
-32680
-32680
-32707
-32707
-32729
-32729
-32746
-32746
-32759
-32759
-32766
-32766
-32768
-32768
-32766
-32766
-32759
-32759
-32746
-32746
-32729
-32729
-32707
-32707
-32680
-32680
-32648
-32648
-32611
-32611
-32569
-32569
-32522
-32522
-32470
-32470
-32414
-32414
-32352
-32352
-32286
-32286
-32215
-32215
-32139
-32139
-32058
-32058
-31972
-31972
-31882
-31882
-31786
-31786
-31686
-31686
-31582
-31582
-31472
-31472
-31358
-31358
-31238
-31238
-31115
-31115
-30986
-30986
-30853
-30853
-30715
-30715
-30573
-30573
-30426
-30426
-30274
-30274
-30118
-30118
-29957
-29957
-29792
-29792
-29622
-29622
-29448
-29448
-29270
-29270
-29087
-29087
-28899
-28899
-28708
-28708
-28512
-28512
-28311
-28311
-28107
-28107
-27898
-27898
-27685
-27685
-27467
-27467
-27246
-27246
-27021
-27021
-26791
-26791
-26558
-26558
-26320
-26320
-26078
-26078
-25833
-25833
-25584
-25584
-25331
-25331
-25074
-25074
-24813
-24813
-24548
-24548
-24280
-24280
-24008
-24008
-23733
-23733
-23454
-23454
-23171
-23171
-22885
-22885
-22595
-22595
-22302
-22302
-22006
-22006
-21707
-21707
-21404
-21404
-21098
-21098
-20788
-20788
-20476
-20476
-20160
-20160
-19842
-19842
-19520
-19520
-19196
-19196
-18869
-18869
-18538
-18538
-18205
-18205
-17870
-17870
-17531
-17531
-17190
-17190
-16847
-16847
-16500
-16500
-16152
-16152
-15801
-15801
-15447
-15447
-15091
-15091
-14733
-14733
-14373
-14373
-14011
-14011
-13646
-13646
-13279
-13279
-12911
-12911
-12540
-12540
-12168
-12168
-11794
-11794
-11417
-11417
-11040
-11040
-10660
-10660
-10279
-10279
-9897
-9897
-9513
-9513
-9127
-9127
-8740
-8740
-8352
-8352
-7962
-7962
-7572
-7572
-7180
-7180
-6787
-6787
-6393
-6393
-5998
-5998
-5603
-5603
-5206
-5206
-4809
-4809
-4410
-4410
-4012
-4012
-3612
-3612
-3212
-3212
-2812
-2812
-2411
-2411
-2010
-2010
-1608
-1608
-1207
-1207
-805
-805

  • Prakash,

    The file format you are saving is a .dat file format, where the first line shows a few details about the file itself. To learn about what these numbers mean, open CCS help and search for "data file formats".

    From that point and on, each value is duplicated. I don't exactly know what is the size of the type _iq (16 or 32 bits), but to me this indicates the values on the sin table are 16 bits but your code is duplicating these values when storing them to a 32-bit variable. Or perhaps the values are full 32-bits but the code is corrupting them.

    To validate this code, try to save the data directly from the sin table address using the Memory save option and compare the two.

    Hope this helps,
    Rafael
  • Hi desouza,

    Thanks for your reply. _iq is of type long. Global IQ is 15 and the IQsinTable returns IQ30 values. This duplication effect occurs only when writing the values of IQsinTable to a txt file.
    x = _IQ30toIQ(IQsinTable[y]);
    Instead of &x, I gave IQsinTable in the start address field, but all the values are 0. Any other suggestions?