|
|
View previous topic :: View next topic |
Author |
Message |
deda34
Joined: 08 Mar 2013 Posts: 10
|
Problem compiling with AD9850 |
Posted: Fri Mar 08, 2013 5:09 pm |
|
|
Hi! I need help to interface AD9850 with a PIC18F4550. I tried to use the code posted on this page https://www.ccsinfo.com/forum/viewtopic.php?t=48383 but when I try to compile, I see several errors. These are: expecting a (Expecting a declaration, Expecting a identifier). So I ask you whether if you can help me find a solution to the problems of compiling ?.
Thank you in advance. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9221 Location: Greensville,Ontario
|
|
Posted: Fri Mar 08, 2013 5:22 pm |
|
|
The code that the post refers to is not a complete program.
Rather it appears to just be a basic 'driver'. As such it has to be added into your 'main' program.
Without seeing your 'main' program no one here can tell you where you've gone wrong,t hough it could be a simple syntax error.
Post your real program, being sure to include the compiler version.
hth
jay |
|
|
deda34
Joined: 08 Mar 2013 Posts: 10
|
|
Posted: Sat Mar 09, 2013 8:32 am |
|
|
Thank for rapid reply. The version of my compiler is V4.134. Here you can see the list of program that regards the AD9850
#include <ad9850.h>
AD9850_setup(PIN_C5,PIN_C4,PIN_D3,PIN_D2 );
while(1)
{
AD9850_sweep(20, 100000, 100, 200, true);
}
The errors are in the routine of AD9850, not in the main program |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19496
|
|
Posted: Sat Mar 09, 2013 8:56 am |
|
|
No, you are missing the point.
The ad9850.h 'driver', needs to have the right settings in your main code _before it is loaded_, or it will not compile correctly. You need to generate a small 'main' program, with fuses etc., then load this driver.
It _will not compile_ without the stuff ahead of it that is needed.
If this stuff is present, the other possibility is that you are using MPLAB, and have added this file to source files in this. It won't compile like this either. It should be in the 'include' files.
Best Wishes |
|
|
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
|
|
deda34
Joined: 08 Mar 2013 Posts: 10
|
|
Posted: Sat Mar 09, 2013 1:40 pm |
|
|
This was just the part of main with AD9850.h. The complete program,with fuses, is this:
Code: |
#case
#include <stdlib.h>
#include "Demo.h"
#include <ad9850.h>
//============================================================================
void main() {
setup_wdt(WDT_OFF);
port_b_pullups(TRUE);
output_b(0xFF);
set_tris_b(0b11110000);
set_tris_d(0);
set_tris_c(0);
set_tris_e(0);
set_tris_a(0);
setup_adc(ADC_CLOCK_DIV_64);
#ZERO_RAM
//------------------
AD9850_setup(PIN_C5,PIN_C4,PIN_D3,PIN_D2 );
while(1)
{
AD9850_sweep(20, 100000, 100, 200, true);
} //end loop
} //end main
|
The file "demo.h" is this:
Code: |
#include <18F4550.h>
#device adc=10
#FUSES NOWDT //No Watch Dog Timer
#FUSES WDT128 //Watch Dog Timer uses 1:128 Postscale
#FUSES HSPLL //High Speed Crystal/Resonator with PLL enabled
#FUSES PROTECT //Code protected from reads
#FUSES BROWNOUT //Brownout reset
#FUSES BORV45 //Brownout reset at 4.5V
#FUSES PUT //Power Up Timer
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES WRT //Program Memory Write Protected
#FUSES NOIESO //Internal External Switch Over mode disabled
#FUSES NOPBADEN //PORTB pins are configured as digital I/O on RESET
//#FUSES BBSIZ1K //1K words Boot Block size
#FUSES WRTC //configuration registers write protected
#FUSES WRTB //Boot block write protected
#FUSES CPB //Boot Block Code Protected
#FUSES NOXINST //Extended set extension and Indexed Addressing mode disabled (Legacy mode)
#FUSES PLL3 //Divide By 3(12MHz oscillator input)
#FUSES CPUDIV1 //No System Clock Postscaler
#FUSES USBDIV //USB clock source comes from PLL divide by 2
#FUSES NOICPRT //ICPRT disabled
#FUSES MCLR //ext reset pin
#use delay(clock=48000000)
// porte, LATx, per la scrittura
#byte port_A=0xF89
#byte port_B=0xF8A
#byte port_C=0xF8B
#byte port_D=0xF8C
#byte port_E=0xF8D
// ADC
unsigned int16 ADRES;
#locate ADRES=0xFC3
#byte ADCON0=0xFC2
#byte EECON2=0xFA7
#byte EECON1=0xFA6
#byte EEDATA=0xFA8
#byte EEADR=0xFA9
#byte INTCON=0xFF2
#byte FAA=0xFAA
#byte PIR1=0xF9E
#byte TXREG=0xFAD
#byte tris_port_B=0xF93
unsigned int16 TIMER0;
#locate TIMER0=0xFD6
//#use rs232(baud=9600,parity=N,bits=8,xmit=PIN_C6,rcv=PIN_C7)
// ROTOR #A
#ROM 0xF00000= {65L} // ROTOR TYPE 'A'
#ROM 0xF00002= {0L} // LOWLIM
#ROM 0xF00004= {3600L} // UPLIM
#ROM 0xF00006= {1L} // INV_DELAY
#ROM 0xF00008= {0L} // ENA_PWM
#ROM 0xF0000A= {12L} // PWN_ON_VALUE
#ROM 0xF0000C= {0L} // PWM_OFF_VALUE
#ROM 0xF0000E= {100L} // RAMP
#ROM 0xF00010= {6L} // MIN_ON_VALUE
#ROM 0xF00012= {0L} // POS_OFFSET
#ROM 0xF00014= {1L} // ROTATION_CHECK
#ROM 0xF00016= {3049L} // ROTATION_TIMEOUT
#ROM 0xF00018= {0L} // SOUTH STOP
#ROM 0xF0001A= {0L} // ZERO_ANGLE_AZI
#ROM 0xF0001C= {1L} // ENA_Z_ANGLE_AZI
// ROTOR #B
#ROM 0xF0001E= {69L} // ROTOR TYPE 'E'
#ROM 0xF00020= {0L} // LOWLIM
#ROM 0xF00022= {900L} // UPLIM
#ROM 0xF00024= {1L} // INV_DELAY
#ROM 0xF00026= {0L} // ENA_PWM
#ROM 0xF00028= {12L} // PWN_ON_VALUE
#ROM 0xF0002A= {0L} // PWM_OFF_VALUE
#ROM 0xF0002C= {100L} // RAMP
#ROM 0xF0002E= {6L} // MIN_ON_VALUE
#ROM 0xF00030= {0L} // POS_OFFSET
#ROM 0xF00032= {1L} // ROTATION_CHECK
#ROM 0xF00034= {3049L} // ROTATION_TIMEOUT
#ROM 0xF00036= {0L} // SOUTH STOP
#ROM 0xF00038= {0L} // ZERO_ANGLE_ELE
#ROM 0xF0003A= {1L} // ENA_Z_ANGLE_ELE
// sempre a seguire l'ultimo parametro
#ROM 0xF0003E= {0L} // TARGET Elevation
#define TARGET_B_ADD 0x3E
// sempre a seguire l'ultimo parametro
#ROM 0xF00040= {0L} // TARGET Azimuth
#define TARGET_A_ADD 0x1E
// rotor ID sul display, 4 per tipo
#define rotorID_len 14
#define rotorA_id1_add 0xD0
#ROM int8 0xF000D0= {'A','z','i','m','u','t',':'} // rotor #A, type 'A', caratteri 0,1
#define rotorA_id2_add 0xD7
#ROM int8 0xF000D7= {'E','l','e','v','a','t',':'} // rotor #A, type 'E',
//
#define rotorB_id1_add 0xE8
#ROM int8 0xF000E8= {'A','z','i','m','u','t',':'} // rotor #A, type 'A', caratteri 0,1
#define rotorB_id2_add 0xEF
#ROM int8 0xF000EF= {'E','l','e','v','a','t',':'} // rotor #A, type 'E', caratteri 0,1
unsigned int32 const DEF_FULL_SCALE = 12506;
unsigned int32 const DEF_FULL_SCALE_B = 12506;
#ROM 0xF000FC= {DEF_FULL_SCALE,0L} // CAL_FACT Azimuth
#define full_scale_ee_A_add 0xFC
#ROM 0xF000F8= {DEF_FULL_SCALE_B,0L} // CAL_FACT Elevation
#define full_scale_ee_B_add 0xF8
// addresses in FRAM
#define POSITION_A_ADD 0xAA
#define POSITION_B_ADD 0x55
//
#define wait_1us() delay_us(1)
#use FAST_IO (A)
#use FAST_IO (B)
#use FAST_IO (C)
#use FAST_IO (D)
#use FAST_IO (E)
#byte tris_c = 0xF94
|
I tried the routine in the link, and report errors..
Regards |
|
|
dyeatman
Joined: 06 Sep 2003 Posts: 1933 Location: Norman, OK
|
|
Posted: Sat Mar 09, 2013 3:29 pm |
|
|
The first thing you must do is move DEMO.h above the #case statement...
It MUST be the first line in the main program. _________________ Google and Forum Search are some of your best tools!!!! |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19496
|
|
Posted: Sat Mar 09, 2013 3:35 pm |
|
|
Start with two things:
There is no function 'AD9850_setup' in the driver on the page you claim to be using. Not surprising it is not accepted....
Then if you look at the code it is written to use standard I/O mode. |
|
|
deda34
Joined: 08 Mar 2013 Posts: 10
|
|
Posted: Sat Mar 09, 2013 4:16 pm |
|
|
So, seen that the program is written using standard I/O mode, what can I do to solve my problem?
Thank you very much for reply |
|
|
deda34
Joined: 08 Mar 2013 Posts: 10
|
|
Posted: Sun Mar 10, 2013 7:10 am |
|
|
I finally understand the reason I could not run the library.
The problem was that the routine had to be inserted before '#case ' otherwise it would made a distinction between upper and lower case. Thank you all for helping me.
Best regards |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|