473,732 Members | 2,175 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before '{' token

8 New Member
Hi
I am using WINAVR compiler for ATMEGA32. While compiling c progam , I am getting the error
error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribu te__’ before '{' token
before evrey function.

code:


Expand|Select|Wrap|Line Numbers
  1. #include <avr\io.h>
  2.  
  3. #include <stdio.h>
  4.  
  5. #include <avr\delay.h>
  6.  
  7. #include <math.h>
  8.  
  9. void initialize(void);
  10.  
  11. char val;
  12.  
  13.  
  14.  
  15. // current measurement state
  16.  
  17. enum {PULSE, GSR, BREATH} measure, nextmeasure;
  18.  
  19.  
  20.  
  21. // current signal voltages
  22.  
  23. char pulseV = 0;
  24.  
  25. char gsrV = 0;
  26.  
  27. char breathV = 0;
  28.  
  29.  
  30.  
  31. // enter every 100Hz
  32.  
  33. interrupt(TIM0_COM) void getAD(void)
  34.  
  35. {
  36.  
  37.     // sample A/D and store
  38.  
  39.     val = ADCH;
  40.  
  41.     // start a/d converter
  42.  
  43.     switch(measure)
  44.  
  45.     {
  46.  
  47.         case PULSE:
  48.  
  49.             pulseV = val << 1;
  50.  
  51.             nextmeasure = GSR;
  52.  
  53.             break;
  54.  
  55.         case GSR:
  56.  
  57.             gsrV = val;
  58.  
  59.             nextmeasure = BREATH;
  60.  
  61.             break;
  62.  
  63.         case BREATH:
  64.  
  65.             breathV = val;
  66.  
  67.             nextmeasure = PULSE;
  68.  
  69.             break;
  70.  
  71.     }
  72.  
  73.  
  74.  
  75.     switch(nextmeasure)
  76.  
  77.     {
  78.  
  79.         case PULSE:  ADMUX = 0b01100001; break;
  80.  
  81.         case GSR:    ADMUX = 0b01100010; break;
  82.  
  83.         case BREATH: ADMUX = 0b01100011; break;
  84.  
  85.     }
  86.  
  87.     measure = nextmeasure;
  88.  
  89.  
  90.  
  91.     ADCSR.6 = 1;
  92.  
  93. }
  94.  
  95.  
  96.  
  97. // send signals to MATLAB for drawing
  98.  
  99. void transmit()
  100.  
  101. {
  102.  
  103.     printf("%d ", (int)pulseV);
  104.  
  105.     printf("%d ", (int)gsrV);
  106.  
  107.     printf("%d ", (int)breathV);
  108.  
  109.     printf("\r");    // end packet
  110.  
  111.     PORTD.7 = ~PORTD.7;
  112.  
  113. }
  114.  
  115.  
  116.  
  117. // read A/D converter and communicate with MATLAB
  118.  
  119. void main(void)
  120.  
  121. {
  122.  
  123.     char inchar;
  124.  
  125.  
  126.  
  127.     initialize();
  128.  
  129.  
  130.  
  131.     while(1)
  132.  
  133.     {
  134.  
  135.         // when signaled by MATLAB, return current values
  136.  
  137.         if (UCSRA.7)
  138.  
  139.         {
  140.  
  141.             inchar = UDR;
  142.  
  143.             if (inchar=='s') {
  144.  
  145.                 transmit();
  146.  
  147.             }
  148.  
  149.         }
  150.  
  151.     }
  152.  
  153. }
  154.  
  155.  
  156.  
  157. // setup
  158.  
  159. void initialize(void)
  160.  
  161. {
  162.  
  163.     // comm indicator LED
  164.  
  165.     DDRD.7 = 1;
  166.  
  167.     PORTD.7 = 0;
  168.  
  169.  
  170.  
  171.     // serial RS-232  setup for debugging using printf, etc.
  172.  
  173.     UCSRB = 0x18;
  174.  
  175.     UBRRL = 103;
  176.  
  177.  
  178.  
  179.     // set up timer0 to sample a/d at about 100Hz
  180.  
  181.     TCCR0 = 0b00000101;
  182.  
  183.     TIMSK = 0b00000010;
  184.  
  185.     OCR0 = 156;
  186.  
  187.  
  188.  
  189.     // set up a/d for external Vref, channel 0
  190.  
  191.     // channel zero / left adj / AVcc Reference
  192.  
  193.     // A1=PULSE, A2=GSR, A3=BREATH
  194.  
  195.     ADMUX = 0b01100001;
  196.  
  197.  
  198.  
  199.     // enable ADC and set prescaler to 1/128*16MHz=125kHz
  200.  
  201.     // and clear interupt enable
  202.  
  203.     // and start a conversion
  204.  
  205.     ADCSR = 0b11000111;
  206.  
  207.  
  208.  
  209.     measure = PULSE;
  210.  
  211.     _sei();
  212.  
  213. }
Oct 18 '09
10 32021
I have had this error and found that there was a ";" missing at the end of one of the statements in one of my .h files.
Nov 17 '10 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

4
3572
by: jakkem | last post by:
For example the following gives me error "expected `(' before '{' token" "expected asm body before '{' token " etc. int main() { asm { /* some asm-functions */ } }
5
2403
by: ritesh | last post by:
Hi, I'm compiling the following code on linux/cc and keep getting a compiler error "attrib.c:4: syntax error before '{' token" I'm using the following options to compile - cc -Wall -c attrib.c #include "stdio.h"
3
3316
by: creativeinspiration | last post by:
Hey guys. I am trying to implement a system call in linux kernel. I usually use ubutntu, but this I am doing on Fedora. I am using kernel 2.6. Here is what I did: 1. Added a line to arch/i386/kernel/syscall_table.S: .long sys_foo 2. Added a line to linux/include/asm-i386/unistd.h: #define __NR_foo 324
1
2713
by: m.selvakannan | last post by:
hi iam working with uclinux i got errors while compilation.. /opt/uClinux/bfin-uclinux/bfin-uclinux/runtime/usr/include/asm/ system.h: In function 'long unsigned int __cmpxchg(volatile void*, long unsigned int, long unsigned int)': /opt/uClinux/bfin-uclinux/bfin-uclinux/runtime/usr/include/asm/ system.h:204: error: expected type-specifier before ')' token
2
1655
by: entellus | last post by:
I'm using gcc to compile the code listed below when I get the following error error: expected '=', ',', ';', 'asm' or '__attribute__' before ' is_prime_number /* * What is the largest prime factor of the number 317584931803? */ #include <stdio.h>
2
8148
by: kya2 | last post by:
I am not able to create following store procedure. CREATE PROCEDURE DBSAMBA.InsertDeleteBatch(OUT norows INT ) RESULT SETS 1 LANGUAGE SQL BEGIN part1 DECLARE TOTAL_LEFT INT DEFAULT 0; SELECT COUNT(*)INTO TOTAL_LEFT FROM DBSAMBA.REPORTEDTRANSACTION_S; WHILE (TOTAL_LEFT > 0) DO
4
2372
by: ...vagrahb | last post by:
Hi, I have the following structure struct Format { char x; unsigned char a; unsigned char b; unsigned char c; char y;
7
70307
by: singhPrabhat | last post by:
Hi, I am using gcc (GCC) 4.2.1 (SUSE Linux). SUSE 10.3 While compiling a .c file I get following error :::: CCWebConfiguration.h:70: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘extern’ CCWebBrowser.c: In function ‘main’:
2
6359
by: akhilesh.noida | last post by:
I am trying to compile glibc-2.5 for ARM based board. But I am getting errors while configuring it. Please check and give your inputs for resolving this. configure command : $ ../glibc-2.5/configure --prefix=/mnt/new/Mars/glibc_HQ_test/GLIBC/ install/ --with-__thread --enable-kernel=2.6.11 --enable-shared
0
8773
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9445
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9234
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9180
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6733
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Duprι who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6030
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4548
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3259
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2721
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.