Re: [avr-gcc-list] basic UART problem / example
Hello, A lot about serial port programming has been discussed in the avrfreaks forum. This is the best place to get answers. Nayani P --- Przemek Urbanski [EMAIL PROTECTED] wrote: Hey, I am new to avr programming. I can not get my at90s8515 talk to rs232. I wrote basic interrupt driven program for at90s8515 talking via UART to rs232 on my PC. Compiled using CodeVisionAVR. It worked fine. Now I am using: avr-gcc (GCC) 3.4.4 binutils 2.15 avr-libc 1.2.3 on linux (Fedora Core 3) Could you please send me, or point me any UART examples, which works compiled with avr-gcc? Thnx AVR freaks : P -- Zobacz projekt nowej strony glownej portalu INTERIA.PL http://link.interia.pl/f188f ___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list __ Discover Yahoo! Get on-the-go sports scores, stock quotes, news and more. Check it out! http://discover.yahoo.com/mobile.html ___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
Re: [avr-gcc-list] PEN on atmega128
--- Torsten Mohr [EMAIL PROTECTED] wrote: i wonder if anybody ever successfully used an ATMega128? I always assumed that. We have been using ATMega128 without any problems for more than a year. We use the SPI bus to program the chip with AVRISP. On some occations used JTAG programmer. Has anything changed in the specs? Does anybody else experience problems with this chip? Regarding PEN, as it is not on the programming connector i think it just has to be either low or high, but can not be changed during programming, right? Though I dont have the schematics right now, AFAIK, ISP uses RESET, MISO,MOSI and the SS pins only. PEN is to be left un-connected. I found out that after disconnecting the power i can do exactly one step of either: - erase - program - verify Now i got the problem that the program does not do what i expect it to do: int main(void) { volatile unsigned int i; volatile unsigned char p = 0; WDTCR = 0x1f; WDTCR = 0x00; DDRD = 0xFF; PORTD = 0x0f; DDRB = 0xFF; PORTB = 0x0f; do { PORTB = p++; //while (PINB 0x01); //for(i = 0; i 100; i++); } while(1); return 0; } Is there an obvious error in it? I can't see the pattern 0x0f on Port D and all pins on Port B are near 0 V. To test this program, set optimization to 0 in make file (O = 0). There is no external crystal soldered on the board, it should start and run anyway, right? Yes it will work if you enable the internal osc of the chip. regards Nayani P __ Discover Yahoo! Use Yahoo! to plan a weekend, have fun online and more. Check it out! http://discover.yahoo.com/ ___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
[avr-gcc-list] bootloader help
Hello all, Perhaps there is ready documentation on bootloader, but I have not been able to get what I wanted. How does one declare a programme to be bootloader program? that is the code must be loaded in the bootsection when I program the chip using avrisp. How does one set the starting address of this code? this is needed as there are different boot loader program sizes. I want to laod programme in the boot section which will test a port bit and jump to if not low. From I want to laod a sample program which may pulse an LED. How can I do this? Thank you all. Regards Nayani P __ Discover Yahoo! Use Yahoo! to plan a weekend, have fun online and more. Check it out! http://discover.yahoo.com/ ___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
Re: [avr-gcc-list] output current for ATMega128 on output pins
Torsten, AVR data sheets talk about 25 mA current per pin., but there is some limitation on the total current drawn. If you are planing to drive some LEDs (4/5) I think you can drive them directly from the port pins. You may consider sinking current to switch the LED ON rather than on sourcing current. Regards Nayani P --- Torsten Mohr [EMAIL PROTECTED] wrote: Hi, how much current i can output on a port. I'd like to drive some LEDs. __ Discover Yahoo! Stay in touch with email, IM, photo sharing and more. Check it out! http://discover.yahoo.com/stayintouch.html ___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
Re: [avr-gcc-list] bootloader: replace bootloader with a new bootloader
Hello, This is something many wish, but unfortunately not possible. Nayani P --- Torsten Mohr [EMAIL PROTECTED] wrote: Hi, i wonder if it is possible to replace a bootloader in an ATMega128 with a new version. Is this possible in a secure way so that a power failure or communication failure does not leave the system in an inconsistent state? So to say that it is possible to re-start the re-programming again after a failure? What design options need to be considered to do this? Best regards, Torsten. ___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list __ Do you Yahoo!? Make Yahoo! your home page http://www.yahoo.com/r/hs ___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
Re: [avr-gcc-list] memory layout for bootloader
Hello, if you want to place other functions in the bootloader memory add the attribute to these functions as well. Ideally one must set the address of .text to boot address, as bootloader is a completely independent program. I tested by putting the .text in the bootloader section and it worked fine. Or are there some disadvantages in this way? I found one disadvantage or rather I am looking for a solution. If one creates a complete program including the main function and put .text in the bootloader memory, the startup code, the interrupt vector table and ofcourse the cleanup code are also added to the binary/hex image. If one is not using any interrupts in the bootloader, why waste this memory? similarly why occupy some more memory for cleanup as this may never be used? I found this to be a disadvantage. How does one avoid putting interrupt table and cleanup code in the bootloader section? (this is what I am looking for) I guess i use 0x1E000, as 0xF000 seems to be based on 16 bits per address, is that correct? The data sheets talk about word address so you need to get the byte address by shifting the bootloader address , mentioned in the docs, left by 1 I assume that the ATMega128 can execute program in all its 128kB, is that correct? Yes. Can i really DISABLE SPI programming by fuse bit SPIEN? Never tired this. Regards Nayani P __ Discover Yahoo! Have fun online with music videos, cool games, IM and more. Check it out! http://discover.yahoo.com/online.html ___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
Re: [avr-gcc-list] double precision bit representation
Hello, Currently avr-gcc supports only float and not double. The byte pattern given in your query results in a float value of -1.135254 Nayani P --- Kitts [EMAIL PROTECTED] wrote: Hi all, I would like to know how a variable declared as double is represented with avr-libc. What is the maximum and minimum values that it can represent and with what resolution? I am performing floating point math which fails in certain occasion where i think it shouldn't. Hence my query... For an example i have a double variable called TempDouble which is placed at the following address in SRAM with each of the byte having the given value. How do i interpret this value in decimal? Ram Address: $0B6F $0B70 $0B71 $0B72 Value:00 50 91 3F Thanks in Advance. -- Cheers! Kitts ___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com ___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
Re: [avr-gcc-list] simple USART (RS232) example for ATmega48
--- [EMAIL PROTECTED] wrote: Hi all, i'm looking for a simple c (AVR-GCC) example program demonstrating the use of the USART0 (as RS232) of my ATmega48. Hello, Here are some program snippets. The following functions are written for Mega8. Please change the name of registers if need be. void USART_Init(void) { UBRRH = 0x00; UBRRL= 47; // 9600 baud rate for external 7.6 MHz crystal UCSRB=0x98; UCSRC=0x86; } // send one byte converted to ASCII void sendbyte(unsigned char dat) //function to send 0x38 as '3' and '8' onto serial port { unsigned char ftmp; ftmp = (dat 4); ftmp += (ftmp 9 ? 0x37 : 0x30); sendchar(ftmp); // transmit the character to hyperterminal ftmp=dat 0x0f; ftmp += (ftmp 9 ? 0x37 : 0x30); sendchar(ftmp); } // send one ASCII character to serial port void sendchar(unsigned char dat) { UDR=dat; while(!(UCSRA 0x40)); UCSRA|= 0x40; } // send a string to serial port void USART_TRANS(unsigned char *ptr) { while(*ptr) { UDR=*ptr++; while (!(UCSRA 0x40)); //Wait for transmission complete UCSRA = 0x40; } } HTH Nayani P Start your day with Yahoo! - make it your home page http://www.yahoo.com/r/hs ___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
RE: [avr-chat] Re: [avr-gcc-list] AVR ISP Error
Hello everybody, There is no switch in the ISP unit. One has to open the covers and there is a provision on the PCB to solder a two pin jumper (taken out of berg connector). Once the soldering is done, plug in the jumper and power up the unit and after a short while the jumper can be removed. Now the unit ready to program. Note: the power to the ISP is drawn from the target board and through the ISP programming connector. While the ISP unit is being upgraded, the MISO,MOSI and other pins must not be connected to the target board. Therefore use only power and ground pins of this ISP connector to power up the ISP unit. I do agree that this is a bit of a long procedure, but thats the system is designed. Nayani Jim Brooks [EMAIL PROTECTED] wrote: There is no button in the AVRISP. In the docs somewhere it says to power theAVRISP( the led comes on, cycles colors and settles on green I think). Youshould not connect it to your target as this usually mungs communicationswith the micro's in the ISP. Once the AVRISP is idle(green status led),clock OK to program it.This is a real pain and your lucky. In my experience, a lot of the time, theISP will mung code in it's secondary MCU and become dead. Atmel has anappnote on recovering but I have yet to be successful.This message will happen every time you update studio, a choice I think abig mistake. The funcinality should have been left in AVRStudio and the ISPcode left frozen.Hope this helps.Let us know how you make out.Jim-Original Message-From: [EMAIL PROTECTED][mailto:[EMAIL PROTECTED] Behalf OfDaniel MayoSent: Thursday, August 25, 2005 6:23 AMTo: AVR GCC List; AVR ChatSubject: [avr-chat] Re: [avr-gcc-list] AVR ISP ErrorWhere is the 'program' button on the AVRISP?Andi Suhandi wrote:To Upgrade the firmware you have to:1. Turn off the STK2. Press "Program" Button on STK3. Turn on the power STK ("Program" button still pressed)4. Run the "Upgrade.exe" program in directory C:\Program Files\Atmel\AVRTools\STK500 Press "Start Upgrade" button5.Then you can release "Program Button"6. Wait till upgrade doneI hope it will helpAndi- Original Message -From: "Daniel Mayo" <[EMAIL PROTECTED]>To: "AVR GCC List"; "AVR Chat" Sent: Thursday, August 25, 2005 3:17 AMSubject: [avr-gcc-list] AVR ISP ErrorI just got two new AVR ISPs from Digikey and am getting this error whenI try to connect to them via AVR Studio 4.11 Build 401 which seems to bethe latest at atmel.com"An AVRISP with firmware version 2.01 has been detected. The firmwarecorresponding to this installation of AVR Studio is 2.00. Press OK tolaunch the upgrade program to perform a downgrade, or Cancel withoutdowngrading. NOTE! Correct operation is not guaranteed if a downgradeis not performed."If I press Cancel it seems as though everything works.If I press Ok, AVR Studio launches the Atmel STK500/AVRISP Upgradeprogram but after doing something to the AVRISP so that the LED goes outit then reports that no programmer could be found, and thus no update isperformed, and then AVR Studio can't detect the AVRISP until I close AVRStudio AND cycle power to the AVRISP.How do I get rid of either the first warning or the error updating sothat I can resolve this?I have looked online at atmel.com and avrfreaks.com, with no luck.___AVR-GCC-list mailing listAVR-GCC-list@nongnu.orghttp://lists.nongnu.org/mailman/listinfo/avr-gcc-list___AVR-chat mailing listAVR-chat@nongnu.orghttp://lists.nongnu.org/mailman/listinfo/avr-chat___AVR-GCC-list mailing listAVR-GCC-list@nongnu.orghttp://lists.nongnu.org/mailman/listinfo/avr-gcc-list___AVR-GCC-list mailing listAVR-GCC-list@nongnu.orghttp://lists.nongnu.org/mailman/listinfo/avr-gcc-list__Do You Yahoo!?Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com ___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
Re: [avr-gcc-list] Small program for UART not working
Hello, Some questions, which may lead to solving the problem. 1. Are ysing external crystal? if yes, did you set bit to external crystal. If you aare using internal 4M clock, then please refer the doc on possible baud rates and their errors. If internal clock is used I suggest you use lower baud rate (less than 115200) and which has the least error. 2. One way to check if received data is correct or not, switch ON some specific LEDs for a particular byte received. example switch ON LED1 if received byte is A, switch on LED2 if received byte is B etc. Since you are shorting the TX and RX lines and if the controller transmits A continously and if the same is received or not can be verified. I hope this will atleast give you some pointer to the actual problem. Regards Nayani --- Gary Bi [EMAIL PROTECTED] wrote: Hi David and Ian, Thanks for the help. I checked the fuses for mega101 mode, it did set to ON. I uncheck it in AVR studio and program it, but this did not make improvement to the issue. I shorted the PIN2 and PIN3 at the end of cable (the end plugs to PC RS232), I still can see the data was received through the loopback, demonstrated through LEDs on STK board. The RS232 cable is good, since I short the other end, I can see the chars typed displayed on the termial. I'm suspecting the baud rate was not set accurately in Atmega128L, so cause the reception of PC side is not synchronized. For example, if I set to 115200, but not accurate, the number could be set as 115000, so I have some errors in PC terminal. I tried to calculate the baud rate on scope, I found I can't get a exactly number, I can only get an estimate. Do you know if there's way to set the baud rate accurately? Thanks, Gary --- David Brown [EMAIL PROTECTED] wrote: Hi, Since you can see the data on your scope, and loopback works fine when shorting RX and TX pins, there seems to be nothing wrong with the microcontroller. The things I would now check are the baud rate (using the scope), the RS-232 line drivers, the TX-RX orientation (I've fixed many communications problems by swapping the TX and RX lines !), the cable between the board and the PC (including the ground line), and the PC serial port. It can be worth shorting the TX and RX pins at the board end of the cable and testing loop-back from the PC side using TTP. mvh., David Hi David, Thanks for the info. I downloaded Tera Term Pro and installed it in my PC, it's a defenitely a better terminal simulation. Unfortunately I got the same result. My problem are: 1. Atmel128L has successfully sent out characters in TX, but I can not receive it correctly in PC termimal. When monitoring the TX pin in scope, I can see char 'B' has been sent out continuouly. /* UART Transmit Complete Interrupt Function */ SIGNAL(SIG_UART0_TRANS){ outp('B',UDR0); } When I short TX and RX pin together in Atmel STK board, I can see the 'B' was displayed correctly (demonstrated using LEDs, PIN7-0 is for Bit7-0). /* UART Receive Complete Interrupt Function */ SIGNAL(SIG_UART0_RECV){ RxChar = inp(UDR0); outp(RxChar, PORTB); } What I receivd in TTP teminal is 0xA2 instead of character 'B' (0x42). 2. I did not set baud rate in the codes for Atmel, in TTP, I will need to set the baud rate to 57600, 8-N-1 to get the RX working, so if I type 'C', I can see the LEDs is demonstrated 'C' correctly. If the set the baud rate to 9600, 115200, etc. I can not get the Rx working. This is very strange. So I have to comment out the two lines for baud: //outp(0x0, UBRR0H); //outp( (u08)UART_BAUD_SELECT, UBRR0L); The MCU is running at 7.3728Mhz, I set the baud parameter to 0x2F according to the datasheet. #define UART_BAUD_SELECT 0x2F //9600 baud There's typo in my previous email, what I want to say is: I can see the character 'B' is sending out, I just did not receive it correctly in PC. 3. Do you think it's possible it's related to a defect MCU (ATMEGA128L)? I'm trying to buy a new MCU(order ATMEGA128-16AI (16Mhz), but not sure if it will work with 7.3728MHz crystal on STK or not. Thanks, Gary == #include avr/io.h #include avr/interrupt.h #include avr/signal.h #include avr/pgmspace.h #define outp(a,b) b=a #define inp(a) a typedef unsigned char u08; typedef unsigned short u16; #define UART_BAUD_SELECT 0x2F //9600 baud #define PRG_RDB( addr ) __LPM((unsigned short)(addr)) #define BV(bit) (1 (bit)) /* UART global variables */ volatile u08 RxChar; volatile int i = 0; /* UART Transmit Complete Interrupt Function */ SIGNAL(SIG_UART0_TRANS) { outp(0x43,UDR0); } /* UART Receive
Re: [avr-gcc-list] Global variables and ISRs ???
Hello Vincent, To be able to modify/access a variable in interrupt, declare it as volatile. Secondly, to test your code, turn off optimization (s=0) in your make file. There is a problem in your code also - you are not making flag=0 after you send back the character. HTH. Nayani --- Vincent Trouilliez [EMAIL PROTECTED] wrote: Hi gents, After the highly technical thread that just ended today, I would like to pick your brains on something much lower flying so to speak, sorry for that ! ;-) Problem : on my ATmega32, after several experiments (only just started using it, learning...), I am suffering a big problem. It seems that when I declare a variable as global, then modify it within an interrupt routine, the 'main' function can't see that the variable has been modified, as if it weren't a global variable... hmmm. The concrete case at hand, was that I tried to implement a buffer for incoming data on the UART. The ISR would fill the buffer and update the buffer pointer accordingly. The program in 'main' was checking to see if the pointer was non-zero and if yes, would send characters back to the serial port for me to see/check. I proved that all was working fine, interrupts etc, but somehow, 'main' would always see the buffer pointer as zero (hence would never react), as if the ISR didn't update it. I simplified the program as much as I could, and the problem is still there. Could anyone have a look at the code below ?? It receives characters on the serial port, toggle sa LED to prove that the ISR did get serviced, and sets flag to try and communicate with the 'main' function which fails. 'main' never sees the flag as set :-/ Any help welcome, because I started scratching my head an hour ago, and now I don't have many hair left to pull !! ;-) Regards, -- Vince, extremely annoyed... #include avr/io.h #include avr/interrupt.h #include avr/signal.h unsigned char flag, bin; //global variables void ioinit (void){ DDRD = 0x20;//PD5 as output for the LED PORTD = 0x00; //turn LED off at boot. //set up USART UBRRH = 0x00; UBRRL = 12; //Baud Rate = 9600 UCSRA = 0x02; //mode asynchrone, fast clock UCSRC = 0X86; //asynchronous, no parity, one stop bit, 8 data bits UCSRB = 0x98; //transmitter and receiver enabled, interrupts on receiver flag = 0; sei(); } SIGNAL (SIG_UART_RECV){ bin = UDR; //read incoming character to clear interrupt PORTD = ~PORTD; //toggle LED to prove ISR was serviced flag = 1; //tell 'main' about the event } int main (void){ ioinit (); while(1){ if (flag){ UDR = 'A'; //print a character to prove that the flag was set. } } } ___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com ___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
Re: [avr-gcc-list] Syntax : how to specifiy a binary constant ?
Hello, GCC 3.4.3 must work for foo = 0b; OR foo = 0B; Are you getting compilation errors? Nayani --- Vincent wrote: I tried for example foo = 0b; or foo = b; but neither worked... I am using gcc-avr 3.4.3 and avr-libc 1.2.3 Regards, -- Vince __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com ___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
Re: [avr-gcc-list] very simple program
Hello, In order to set the bit, you need to logical OR the bit. DDRB |= _BV (PB0); to clear it DDRB = ~_BV(PB0); Nayani 4: undefined reference to `__stack' #include avr/io.h int main(void){ while (1) { DDRB = _BV(PB0); }; } __ Yahoo! Mail - PC Magazine Editors' Choice 2005 http://mail.yahoo.com ___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
[avr-gcc-list] startup file
Hello all, I have written a very simple bootloader and it is working OK. I would like to eliminate the intial interrupt vectors to get more flash space. To achieve this I would like to assemble the crtx file. I am not sure if this is the right approach, and therefore seeking your suggestions. Not withstanding the above need I would like to get a copy of the source and also would like to know the steps involved in assembling this file. Thank you. Regards Nayani __ Start your day with Yahoo! - Make it your home page! http://www.yahoo.com/r/hs ___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
Re: [avr-gcc-list] startup file
Hello Bernd Trog, --- Bernd Trog [EMAIL PROTECTED] wrote: Have you tried to remove *(.vectors) from the linker script? Thanks for the reply. I was not sure if one could remove vector table from being linked. I am under the impression that vector table is a part and parcel of the startup file! Can you please post the exact linker script to eliminate vector table? Thank you very much. Regards Nayani __ Yahoo! Mail - PC Magazine Editors' Choice 2005 http://mail.yahoo.com ___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
Re: [avr-gcc-list] (Newbie)2.Delay function not working as required
Hello, What is the code for delayms function? If you have a doubt that optimisation is causing a problem, you could disable optimisation, recompile and check the output (delay time).Regards Nayani Sumeet Pal Singh [EMAIL PROTECTED] wrote: Hi We tried to put delay in our program but it is not that reliable, When we do for(char i=0x00;i100;i++) delayms(100);The output which we get is not 100*100ms but something unexpected. The variable i is not used anywhere else in program. Is it that the optimisation is causing problem, if yes please tell how to remive it.Thanks Sumeet ___AVR-GCC-list mailing listAVR-GCC-list@nongnu.orghttp://lists.nongnu.org/mailman/listinfo/avr-gcc-list Yahoo! Shopping Find Great Deals on Holiday Gifts at Yahoo! Shopping ___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
[avr-gcc-list] sprintf problem
Hello all, In one of my projects (ATMega128 based) I am using floating point numbers and sprintf to write a formatted record to a buffer. Tthe buffer contents is then sent to a mini printer. The first two records print properly and thereafter I am getting garbage from sprintf!! The optimisation was set to 0. When I change the optimisation to s, then correct data is being printed!! Moreover there is a difference in the way _delay_loop_2 and _delay_loop_1 delays are generated with different optimisations. I would like to know the reason why this is happening (specially with sprintf) to avoid any pitfalls in my coding. Thanks in advance.Nayani P Yahoo! Photos Showcase holiday pictures in hardcover Photo Books. You design it and well bind it!___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
Re: [avr-gcc-list] Makefile Changes
Hello Sumeet,If you do not make changes to the source, then why compile again? If you do make changes, WinAvr will compile.RegardsNayaniSumeet Pal Singh [EMAIL PROTECTED] wrote:Can someone suggest some way(part of code of Makefile to change) to make avr-gcc to compile irrespective of whether the source file has been modified on not. I am not good in shell scripting. ThanksSumeet Do you Yahoo!? Everyone is raving about the all-new Yahoo! Mail Beta.___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
[avr-gcc-list] Is this what we get for trying to help?
Dear all,I have been following this list for more than a year to learn GCC better and offer suggestions as and when felt that I was capable of offering a comment to any of the posts. Though I was not posting any replies in the recent past, I had been folowing the topics. I had posted some questions earlier and they appeared in this list but surprisingly my replies to this list are not appearing ant threfore, I have included the personal mail id of Mr. Joerg Wunsch.Recently I saw a post and replied to it and got the following reply from the sender. I sent my reply with an intension of helping the student, but please see the mail I received. I copy paste the contents for your perusal. hello , 1 . i want to tell you that the connections can be changed ifu get the working code . 2 . i want to tell you that the program can be modifiedaccording to our own needs . 3 . Dont try to become oversmart . People other than you have theexperience of writing a code . 4 . Avoid sending your stupid replies in case you dont have theanswer to what the user asked for . 5 . The only conclusion is that you are idiot .Have fun with your own replies you idiot Ankur Handa On Fri, 13 Oct 2006, Parthasaradhi Nayani wrote: Hello, How can you use working code of one board (whose connections may be different from yours) on your board? All you need to know is the initialisation sequence and writing commands/data. Is you LCD connected in 8 bit mode or 4 bit mode? Check the following link for example code. www.lampex.com Best wishes Nayani P Ankur [EMAIL PROTECTED] wrote: Hello everyone , I am new to this mailing list . I need a favour from you . If anyone has a working code for LCD interfaced to ATmega8 , can you send it to me . I am really in a great need of this . Whatever i wrote is not working properly . Thanks in advance Ankur Handa ___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list Thank you all.Regards Nayani P Get your own web address for just $1.99/1st yr. We'll help. Yahoo! Small Business. ___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
Re: [avr-gcc-list] Is this what we get for trying to help?
Dear Mr. David,Thanks a lot for the mail and from now on I will remember to "reply all" rather than just "reply". Your words about the student are very apt and as you rightly said SMS-speak must be out. Thanks once again.RegardsNayaniDavid Brown [EMAIL PROTECTED] wrote: Hi Nayani,The reason your replies don't appear on the list is that this mailing list is set up so that replies are sent to the poster, not the list. I can't remember why it is setup this way, but I remember there was a discussion about it a long time ago. The list moderators and organisers had good reasons for having the list this way - and if Joerg and the others find the list faster or easier this way, then fair enough. The trick for most email clients is to click "Reply All" rather than just "Reply", and adjust the addresses as desired.Regarding the obnoxious student - you just have to ignore such people. It's an unfortunate fact of mailing list (or Usenet) life. On a moderated list like this, they are less of a problem, but there seem to be steadily more students (and, more depressingly, "professionals") who think others should do their work for them, and have no respect or manners. Keep your flame-proof underwear on when posting, and filter out any posts where "you" is spelt "u", or where the poster can't find the shift key (there is nothing wrong with spelling mistakes or grammatical errors - but SMS-speak is right out).Best regards,DavidParthasaradhi Nayani wrote: Dear all, I have been following this list for more than a year to learn GCC better and offer suggestions as and when felt that I was capable of offering a comment to any of the posts. Though I was not posting any replies in the recent past, I had been folowing the topics. I had posted some questions earlier and they appeared in this list but surprisingly my replies to this list are not appearing ant threfore, I have included the personal mail id of Mr. Joerg Wunsch. Recently I saw a post and replied to it and got the following reply from the sender. I sent my reply with an intension of helping the student, but please see the mail I received. I copy paste the contents for your perusal. hello , 1 . i want to tell you that the connections can be changed if u get the working code . 2 . i want to tell you that the program can be modified according to our own needs . 3 . Dont try to become oversmart . People other than you have the experience of writing a code . 4 . Avoid sending your stupid replies in case you dont have the answer to what the user asked for . 5 . The only conclusion is that you are idiot . Have fun with your own replies you idiot Ankur Handa On Fri, 13 Oct 2006, Parthasaradhi Nayani wrote:Hello, How can you use working code of one board (whose connections may be different from yours) on your board? All you need to know is the initialisation sequence and writing commands/data. Is you LCD connected in 8 bit mode or 4 bit mode? Check the following link for example code. www.lampex.com Best wishes Nayani P Ankur <[EMAIL PROTECTED]> wrote: Hello everyone ,I am new to this mailing list . I need a favour from you . Ifanyone has a working code for LCD interfaced to ATmega8 , canyou send it to me . I am really in a great need of this . Whateveri wrote is not working properly . Thanks in advance Ankur Handa ___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list Thank you all. Regards Nayani P Do you Yahoo!? Get on board. You're invited to try the new Yahoo! Mail.___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
Re: [avr-gcc-list] bootloader for hex file on SD/MMC card
Hello Abhijit, I'm a student working with ATMEGA 8, 16 and 32, making autonomous robots for college contests and projects. I'm looking for a bootloader that will search for an SD/MMC card, find a hex file on it and program itself. This will make it quite easy to make hassle-free code changes or upgrades on contest venues, especially so because i can use any pc to load compiled hex files into the memory card.. I doubt if any one can give you a ready made bootloader. Since SD/MMC cards are normally connected to SPI bus, you could write the bootloader to read some specific memory locations on the card (through SPI) for some sort of signature and if present read and program the flash. Nayani - It's here! Your new message! Get new email alerts with the free Yahoo! Toolbar.___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
Re: [avr-gcc-list] if test ignored?
Rick Mann [EMAIL PROTECTED] wrote: On an AVR ATmega128: I have two source files. In Serial.c, I define a global: char sCommandReceived; in the corresponding Serial.h file, I have: extern char sCommandReceived; sCommandReceived is set to 1 when enough bytes have been copied into a buffer from the serial port. In main.c, which includes Serial.h, I have: while (true) { if (sCommandReceived) { parseCommand(); } } One probable cause could be 'sCommandReceived' not declared as volatile if it is being accessed in the interrupt Nayani Choose the right car based on your needs. Check out Yahoo! Autos new Car Finder tool.http://us.rd.yahoo.com/evt=48518/*http://autos.yahoo.com/carfinder/;_ylc=X3oDMTE3NWsyMDd2BF9TAzk3MTA3MDc2BHNlYwNtYWlsdGFncwRzbGsDY2FyLWZpbmRlcg-- hot CTA = Yahoo! Autos new Car Finder tool___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
RE: [avr-gcc-list] Mega2561 compilation problem
Hello Stu Bell, Thanks for your suggestions, but the code compiled using atman AVR is the same code we compiled using WinAvr. Surprisingly the code compiled using WinAvr resets the controller whereas code from Atman does not. We are not using any special SP initialization etc. We are using the default startup files of WinAvr. Thank you. Regards Nayani Stu Bell [EMAIL PROTECTED] wrote:v\:* {behavior:url(#default#VML);} o\:* {behavior:url(#default#VML);} w\:* {behavior:url(#default#VML);} .shape {behavior:url(#default#VML);} st1\:*{behavior:url(#default#ieooui) } Your usage of stack will go up with the 2561, since a subroutine return address is now 3 bytes instead of 2. Be sure that you properly account for that in any stack initialization that you do, and in all code that may use RAM. Best regards, Stu Bell DataPlay (DPHI, Inc.) - From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Parthasaradhi Nayani Sent: Wednesday, June 06, 2007 6:07 AM To: avr-gcc-list@nongnu.org Subject: [avr-gcc-list] Mega2561 compilation problem Hello all, We were using a Mega128 in one of our boards and we had to shift to Mega2561 as the requirement for program memory increased with advanced functional demands. We used Atman AVR demo and the code worked without a hitch. However when we use new (latest) WinAvr, the controller is resetting at one point or the other. We are using many sprintf_P functions to save RAM memory. Any clues, suggestions in helping us solve the problem will be highly appreciated. Thank you. Regards Nayani P - Be a better Heartthrob. Get better relationship answers from someone who knows. Yahoo! Answers - Check it out. - 8:00? 8:25? 8:40? Find a flick in no time with theYahoo! Search movie showtime shortcut.___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
[avr-gcc-list] Assembly language help
Hello Group, I am writing an assembly language function in which I need to get the address of a sub-routine into a register pair. How can I do it? A sample code is given below. ;-- .section .text .global func1 func1: nop nop ; some code ; at this point I would like to get the address of label1 into, say r24 and r25 label1:nop nop ; some code ;- I am using Mega64. Thanks in advance for help rendered. Regards Nayani P - Moody friends. Drama queens. Your life? Nope! - their life, your story. Play Sims Stories at Yahoo! Games. ___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
Re: [avr-gcc-list] Assembly language help
Hello Greg, Thanks a lot. I am now able to get the address. Regards Nayani P Gre7g Luterman [EMAIL PROTECTED] wrote: --- Parthasaradhi Nayani wrote: Hello Group, I am writing an assembly language function in which I need to get the address of a sub-routine into a register pair. How can I do it? A sample code is given below. func1: nop nop ldi r24, lo8(label1) ldi r25, hi8(label1) asr r25 ; convert byte addr ror r24 ; to word addr nop nop label1: nop nop HTH, Gre7g Ready for the edge of your seat? Check out tonight's top picks on Yahoo! TV. http://tv.yahoo.com/ ___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list - Shape Yahoo! in your own image. Join our Network Research Panel today!___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
Re: [avr-gcc-list] Assembly language help
Hello Erik, Erik Christiansen [EMAIL PROTECTED] wrote: http://opensource.cqu.edu.au/cgi-bin/info/info2html.cgi?(as.info)AVR-Modifiers Thanks for the link. This will many people who use assembly language. Few are interested in writing complete assembler programs on the AVR, it seems, though there is some use of gcc's in-line assembler. Perhaps yes, but at some point or the other one is forced to switch to assembly!! A good document on AVR GCC covering all the aspects will go a long way in helping, not only beginners but also experienced programmers as reference book. As mentioned in my earlier mail, I did come across LO and HI, but now I can't get them. Any throw light on this please? Regards Nayani P - Moody friends. Drama queens. Your life? Nope! - their life, your story. Play Sims Stories at Yahoo! Games. ___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
Re: [avr-gcc-list] Reading eeprom without using routines in eeprom.h, causes reset.
Hello, I tested the code on mega8 using winavr release 20070525. No problems were encountered. NPS Michael [EMAIL PROTECTED] wrote: Hi, when I was new to the avr-gcc (and still fairly new to C), I read the eeprom like this: unsigned char eeread(unsigned char address) { while(EECR _BV(EEWE)); EEAR = address; EECR |= _BV(EERE); return EEDR; } Not the ideal way of doing it, but it worked fine. I moved my code over from my debian system to winavr, which had a later version of the compiler. The above code now causes the device to reset. I have experienced this on an Atmega128, and an Atmega8. I can get things working again simply by using the eeprom.h routines in avr-libc, but I believe the above code should still work! I currently have the latest version of winavr, I dont remember which compiler version I was running under debian. Can anybody shed any light on this? Why would the above code cause a reset when it used to work? Regards, Michael. ___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list - Shape Yahoo! in your own image. Join our Network Research Panel today!___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
Re: [avr-gcc-list] Fine Tuning code timings
Hi Alex, I am not sure why you are capturing the timer1 value, unless you are using the timer for other purposes as well. If not then the easiest method is to: 1. Enable time over flow interrupt. 2. Load the timer withe the required delay for the chosen baud rate. The port pin can be made low here itself as the start bit. 3. When the timer over flow occurs, send the bit and re-load the timer with the earlier value (so the interrupt will occur at the same time for the next bit) If your baud rate is high (19,200 or more) then it makes sense to use an 8 bit timer as the higher byte of a 16 bit timer may have to be 0xff. One rough method to get the timing s to pulse the port pin and monitor it on a scope and adjust the timer re-load value. When stop bit is sent, you may stop the timer to prevent unnecessary interrupts eating into processor time. Hope this helps. Partha Alex Shepherd [EMAIL PROTECTED] wrote: Hi Guys, I'm trying to fine tune some C code timing issues for a software UART written in AVRGCC. Essentially when I go to transmit a byte, I capture the value of Timer1, set the output compare value to the current timer value + the bit period, activate the Tx pin and then wait for the interrupt handler to output the rest of the bits in the byte. The problem I'm having is that the latency between the timer interrupt firing and the code in the interrupt handler that drives the pin state is causing some error. I need some way to calculate the amount of time to reduce the initial timer period by so that the pin state driving logic in the interrupt handler executes at the right time. What I would like to try and find out (and why I'm asking on this list): Is there any way to figure out using compiler tricks/magic how far into a function or interrupt handler a line of code is so that I can use this offset value to tune the initial start-bit timer value. The subsequent bit timings are ok as they are generated using the same code path? I have experimented using LABELS in the code and trying to do pointer arithmetic but they don't seem to be accessible outside the function or I was just doing it wrong. Merry Christmas Alex Shepherd ___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list - Never miss a thing. Make Yahoo your homepage.___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
[avr-gcc-list] Binding a register pair to a pointer
Hello all, I have a time critical application where I have to process an external interrupt request. When the interrupt occurs, I have to read a port and store this data pointed by a pointer. In order to reduce the time taken by pushes and pops, I would like to bind a register pair to a char pointer. My search for examples has not yielded any results. I have tried something like unsigned char *ptr asm (x) but this is throwing out an error. Can some one show me an example on how to achieve this? Thank you. Nayani P ___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
RE: [avr-gcc-list] Binding a register pair to a pointer
Hello Weddington, Thanks for the mail, but the FAQ example is as follows: register unsigned char counter asm (r3) The above is an example for a single byte value, but I would like to bind a pointer which is a 16 bit value and perhaps the X register may be used. I tried using constraints also but the complier complains. An example line of code on how to do this will be highly appreciated. Thank you. Regards Nayani --- On Wed, 12/10/08, Weddington, Eric [EMAIL PROTECTED] wrote: From: Weddington, Eric [EMAIL PROTECTED] Subject: RE: [avr-gcc-list] Binding a register pair to a pointer To: [EMAIL PROTECTED], avr-gcc-list@nongnu.org Date: Wednesday, December 10, 2008, 12:45 AM This is describe in the avr-libc user manual, in the FAQ. ___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
RE: [avr-gcc-list] On getting an ISR leaner with GCC
If you look in the avr-libc manual under Frequently Asked Questions you can find FAQ #3: How to permanently bind a variable to a register. That allows you to assign particular registers to variables, although care must be used when using the avr-libc library functions. I had faced a similar situation and some time ago I posted a query for a similar problem. The manual mentions a single register binding and in some cases a pointer may (two registers) may be required for binding and the manual does not talk about such binding. Now that this topic is being discussed, I was wondering if I can solve my problem!! Thank you. P. Nayani ___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
Re: [avr-gcc-list] Failing to share a flag between two files/modules :-/
Hello, I guess there are two variables named flag being created, one in main and the other in ui.c. Please define the global variable in one .C file of your choice and tell the other file by using extern directive. Hope this solves your problem Nayani --- On Sun, 2/8/09, Vincent Trouilliez vincent.trouill...@modulonet.fr wrote: From: Vincent Trouilliez vincent.trouill...@modulonet.fr Subject: [avr-gcc-list] Failing to share a flag between two files/modules :-/ To: avr-gcc-list@nongnu.org avr-gcc-list@nongnu.org Date: Sunday, February 8, 2009, 2:02 PM Hello Gents, I am having problem communicating between main.c and another file/module, ui.c to name it. In main.c I set a flag from a timer ISR, every 100ms. In ui.c I am watching for that flag, but unfortunately it always reads zero :-/ However if I watch for the flag in main() then it works fine. I am watching the flag in ui.c, so I declared it in ui.h, then ui.h gets included in main.c so I can set the flag from there. Well that was my reasoning, but doesn't quite work sadly ! I must be doing something wrong obviously, just would love to learn what it is ! ;-) Regards, -- Vince, a bit stuck and wondering again... ui.h --- static volatile uint8_t flag; ui.c if( flag ) { flag = 0; /* Do some stuff */ } main.c #include ui.h ISR (TIMER0_COMP_vect) { flag = 1; } main() {} ___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list ___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
Re: [avr-gcc-list] How to force GCC to not to remove nop statements ?
Hi Vincent, If I understand correctly, the word volatile itself is to tell the compiler not to ignore the statement. I am not sure if your statement is correct, but I have used asm volatile (nop::); and the compiler never removed the nops from code. Nayani --- On Thu, 2/19/09, Vincent Trouilliez vincent.trouill...@modulonet.fr wrote: From: Vincent Trouilliez vincent.trouill...@modulonet.fr Subject: [avr-gcc-list] How to force GCC to not to remove nop statements ? To: avr-gcc-list@nongnu.org avr-gcc-list@nongnu.org Date: Thursday, February 19, 2009, 11:31 PM Hi list, Like many people I guess, I am using in-lined nop asm statements to respect the timing of external devices, when toggling their control lines. In the case at hand I am driving a text LCD module, and the Enable line must be pulsed low for 250ns. void lcd_send_nibble(uint8_t data) { ... //pulse Enable line LCD_PORT |= LCD_E; __asm__ volatile(nop); __asm__ volatile(nop); __asm__ volatile(nop); __asm__ volatile(nop); LCD_PORT = ~LCD_E; } My AVR was running at 8MHz, so an instruction cycle of 125ns, so two nop in-lined were spot on, just perfect, and it ran fine. Today I pushed the AVR (ATmega32) up to its maximum of 16MHz. So I now need 4 nops not two. So I did that.. and the LCD doesn't work reliably. Suspecting the problem, I went straight to the generated assembly, and horror, my 4 nop statements have disappeared ! I made a few trials. It appears that up to and including 3 nop statements, GCC leaves them alone. But if I put 4 of them, it removes them all ! Any way to instruct GCC to leave my 4 nops ? Am using avr-gcc 4.3.2 Regards, -- Vince ___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list ___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
[avr-gcc-list] introducing a new section in data memory
Hello all, I needed to create a buffer of 256 bytes starting at a page boundary (xx00) in the RAM memory (Mega8). I added this line in the makefile LDFLAGs = -wl,--section-start=.test=0x800200 and defined a variable in the .C file (shown below) unsigned char mem3 __attribute__ ((section(.test))); However variable mem3 is being assigned address 0x60 in the controller??? also if I define another global in next line to mem3 I get error that .data and .bss overlap lma 0xa0?? I am of the opinion that all variable defined with attribute .test will be located in that memory area and all other global variables will be located in their native memory. Perhaps if I ma able locate the .test section properly the overlap error may vanish. Can you correct the problem please? Thank you. Nayani ___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
[avr-gcc-list] introducing a new section in data memory
Hello all, I sent a mail on the subject but it seems to have got lost and therefore posting again I need to have a buffer of about 256 bytes starting at a page boundary in the ram of Mega8. To get this I introduced a new section and assigned it an address in makefile. I defined variables, to test, using attribute section. However when I try to debug the code I see the variables are allotted memory locations other than specified in the section? My makefile has the following statement LDFLAGs = -wl,--section-start=.test=0x800100 My .C file has the following statements unsigned char mem3 __attribute__ ((section(.test))); int mem5 __attribute__ ((section(.test))); I have also noticed, if I declare a global variable I get overlap error. Please help me solve this problem. Thank you. Nayani ___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
RE: [avr-gcc-list] introducing a new section in data memory
--- On Fri, 2/20/09, Weddington, Eric ewedding...@cso.atmel.com wrote: First off, is that a typo above? It's suppose to be an uppercase 'W' like so: LDFLAGs = -Wl,--section-start=.test=0x800200 It was a typo. Will test and reply. Thank you for your time. Regards Nayani ___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
RE: [avr-gcc-list] introducing a new section in data memory
First off, is that a typo above? It's suppose to be an uppercase 'W' like so: LDFLAGs = -Wl,--section-start=.test=0x800200 Hi, Checked the 'W' and it was indeed capital letter only. The problem persists!! Any more suggestions please? Thank you. Nayani ___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
Re: [avr-gcc-list] introducing a new section in data memory
--- On Sat, 2/21/09, Georg-Johann Lay a...@gjlay.de wrote: The trouble might return if .data/.bss will grow and then overlap(s) No sir, I needed 256 bytes buffers two and the other variables may total to about 10 or so. The problem is that you cannot introduce holes in a section, i.e. start with .data, reserve a hole of 0x100 (or put .stuff in it) and then proceed with .data. Therefore, there may be a waste of RAM of up to 0xff bytes. If .data and .test are two adjacent sections, I guess there will be no issue (well they need not be adjacent for that matter). If my .test section starts at a page boundary, it is enough. The only safe way to do this is -- supplying own linker script that introduces alignment as needed. -- supplying own linker script that introduces sections .data.lo at 0x60, .test at 0x100, .data.hi at 0x200. But depending on the size of .data, you will have to split .bss instead and explicitely say that has to go in the .data fragments. Not nice. -- or allocate 0x1ff bytes and compute the effective address at runtime. But then you must access indirect through a pointer. -- Maybe it's best to take the space from the top of RAM. Then you will waste just 0x60 bytes (or can put some other stuff there), and you can use direct addressing if you prefer or need that. Yust init the stach pointer to an other value by means of -minit-stack from command line or simply by __builtin_alloca (0x160) resp. auto char test_buffer[0x160] upon entering main(). Just realize that because your variable is now in the .test section, don't expect the toolchain to automatically initialize the variable to zeros in the future. Thank you for the clue. I will take care to init the section myself. It may do that now, but the toolchain will change to not include the __do_clear_bss if it detects that there is nothing in the .bss section. The variable is now outside the .bss, so there are no guarantees that it will be initialized to a known value (zeros) in the startup code. This can be fixed by renaming the section to .bss.test, as far as you refer to http://lists.gnu.org/archive/html/avr-gcc-list/2009-01/msg00162.html But note that the linker assumes one monolithic section, and resp. does the code in __do_clear_bss resp. __do_copy_data! Also nothe that there are some bugs in the patch cited above. I will fix them as soon I will find the time for it. By the way, what is the specification for the handling of orphans? Seems as if they are assumed to be adopted by .data? Regards Nayani ___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
RE: [avr-gcc-list] introducing a new section in data memory
--- On Sat, 2/21/09, Weddington, Eric ewedding...@cso.atmel.com wrote: It works for me. See attached demo. After the build look at the .map file and the disassembly file (.dis). Just realize that because your variable is now in the .test Attachment error. Trying again for the list. Thank you very much. Will compile, check and revert. Regards Nayani ___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
Re: [avr-gcc-list] How to tell avr-gcc not to use some registers in the whole program?
--- On Sun, 2/22/09, Georg-Johann Lay a...@gjlay.de wrote: You can do this by introducing two global register variables like register foo_t * pfoo asm (r2); Also note the command line option -ffixed-2 -ffixed-3 that turn R2/R3 into fixed registers (in contrast to R2/R3 beeing call-saved-regs, which is the default for them). Also note that you most probably won't experience the desired reduction of program memory and/or execution time. This is because the compiler must move R2 to X, Y, or Z to access a location. Making Y or Z global regs will crash the compiler sooner or later. I would not recommend to make X global, either. In your sample code above only R2 (8 bit) is bound to the variable. I had a similar requirement for using 16 bit (say X register) as pointer, can you post a sample line of code on how to do this? Thank you. Nayani ___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
Re: [avr-gcc-list] Re: C vs. assembly performance
From: Nicholas Vinen h...@x256.org For example, things like unsigned char x, y; x = y4 could use the nibble swap instruction rather than four shifts, and things like Shifting a byte or int right or left must push in 00s from the other side so swapping a nibble is not the right thing to do. So is the case with other examples. Correct me if I am wrong. Nayani ___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
Re: [avr-gcc-list] when is it safe to use -mtiny-stack
The -mtiny-stack may (and should) be used only for devices with 0xFF max RAM adderss, i.e. if SP register is 8-bit. All devices with 1KB and 2KB FLASH memory satisfy this condition, now. Hello all, If the memory size itself is 256 Bytes, naturally SP will be 8 bits and where is the need to explicitly tell the compiler of mini-stack? Is it to generate any stack over flow errors? Thank you. Regards Nayani ___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
Re: [avr-gcc-list] PN problem
Hi everybody, I am using Winavr for some years and now I started having problems with PN recently. When I start PN and open a project and don't open any source files, commands like clean, make all etc., work. But when I open a source file and try the same commands, I get no rule to make error. Where could the problem be and how can rectify it? Thank you for your time and help. Since nobody replied to my post, I am wondering if I am making a stupid mistake which does not require a reply? OR am I the only person to face this problem? Nayani P ___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
RE: [avr-gcc-list] PN problem
From: Weddington, Eric eric.wedding...@atmel.com Subject: RE: [avr-gcc-list] PN problem I don't deal much with PN projects. But I would suspect something within the .pnps file. IIRC, this file is XML. Perhaps there is some path issue written in the project file... Hi, Thank you very much for the reply. I had another copy of PN2 installed and I think this was causing the problem. I uninstalled this copy and tried using the one that came with WinAvr. This seems to work, provided the Makefile is in the source directory. Best regards Nayani P ___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
[avr-gcc-list] Storing variables in external memory - suggestions
Hello all, I was wondering if any one can suggest a decent method of automatically assigning address space to variables in external EEPROM. For internal EEPROM the attribute EEMEM will allocate addresses in sequence. One can insert or delete a variable and the address space gets adjusted properly. Is there a method of doing something similar for external EEPROM. I have an external EEPROM where I would like to store and retrieve variables. Thanks in advance for your suggestions. Regards Nayani P ___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
Re: [avr-gcc-list] Storing variables in external memory - suggestions
--- On Fri, 5/22/09, David Kelly dke...@hiwaay.net wrote: All EEMEM does is this in eeprom.h: #define EEMEM __attribute__((section(.eeprom))) AVR Studio convention is that internal .eeprom starts at 0x0081. So what I'd do if I were you and wanted the compiler to assign static memory addresses in an external eeprom would be: #define EEEXT __attribute__((section(.eeexternal))) Then in my Makefile (or somewhere in AVR Studio) would add this to the linker definitions (am not certain 0x00a1 is available): LDFLAGS+=--section-start=.eeprom=00a1 If you put initialized definitions in EEEXT they will be lost. Your code has to write them in the external device because neither the compiler nor AVR Studio knows how. You can add a rule to the Makefile (if you are using make) to write a hex file containing your external EEPROM initial values: %_eeext.hex: %.elf avr-objcopy -j .eeexternal --change-section-lma .eeexternal=0 -O ihex $ $@ Then you need a target such as this which will invoke the above rule (think it needs a blank line after): object_eeext.hex: Finally, believe it goes without saying that you have to provide routines to access your external EEPROM device. Hello David Kelly, Thanks a lot for the suggestions. Yes, I understand that initializing the variables will not actually save the vales into the memory locations. I will try a sample code and revert. Thanks once again. B Regards Nayani P ___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
Re: [avr-gcc-list] Storing variables in external memory - suggestions
--- On Fri, 5/22/09, David Kelly dke...@hiwaay.net wrote: AVR Studio convention is that internal .eeprom starts at 0x0081. So what I'd do if I were you and wanted the compiler to assign static memory addresses in an external eeprom would be: #define EEEXT __attribute__((section(.eeexternal))) am not certain 0x00a1 is available. LDFLAGS+=--section-start=.eeprom=00a1 Hello David Kelly, I tried as you mentioned and seems to work fine. One more question is, how to know the address ranges used by WinAVR? so one can use the unused ranges for external EEPROM, FLASH etc. Thank you. Regards Nayani P ___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
[avr-gcc-list] Memory problem
Hello all, I have interfaced flash memory to my mega64 and created a section for this memory. I have some variables and two structures which are located in this memory. Initially I defined the variables first and then the structure. After linking I checked the map and list files and found that the first defined variable occupied the first memory location and so on. Later I moved the structure to the top and compiled again but this time the variables remained in the same old order (the structure should have occupied the first byte onwards). Why is this happening? If I need to put some variables in some fixed address in this memory how can I do it? Thanks in advance for your help. Regards, Parthasaradhi Hyderabad ___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
Re: [avr-gcc-list] Memory problem
--- On Mon, 6/22/09, David Kelly dke...@hiwaay.net wrote: Study the include files for register definitions for a means of controlling the absolute address of allocation. Thank you David Kelly for your response. I will sieve through the header files to know how to allocate a variable to a memory location. Regards, Parthasaradhi Hyderabad ___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
Re: [avr-gcc-list] Memory problem
--- On Tue, 6/23/09, Joerg Wunsch j...@uriah.heep.sax.de wrote: The only method to not have the linker reorder your variables is to just use a single variable (per memory section). So, put some kind of an embracing struct around all your variables you'd like to have in a particular order, and you'll be done. Thank you very much for your suggestion. In case I declare all the variables in a structure then accessing each variable will require using the structure name.variable name! However I would like to assign a memory to a variable also therefore can you suggest how I can do this? Thanks once again for your support. Regards, Nayani P ___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
Re: [avr-gcc-list] Memory problem
--- On Tue, 6/23/09, David Kelly dke...@hiwaay.net wrote: Something like this might work for you: typedef struct { uint8_t variable; uint16_t a, b, c, d; uint32_t e; } FLASH_STRUCT; #define flash_p ((FLASH_STRUCT *)(0x8000)) Hello David Kelly, Thanks a lot for taking time to enlighten me on these issues. As you had suggested to one of my earlier posts, I created a section and named it EXFLASH and put my variables there, many of them strings. I had a horrid time trying to find out why a structure defined thus struct EXFLASH mystruct tempstruct; had some weird values. When I checked the map file the named structure was allotted space in RAM!! Finally I changed the above to struct mystruct EXFLASH tempstruct; and the structure was allotted space in EXFLASH. Phew!!! I finally got the struct into FLASH (this will help others in future I guess) I created one more in RAM and copied the FLASH content to this stuct and able to access members witout difficulty. Any pointers on fixed memory allocation will really help. Thanks once again to you and Joerg. Regards, Nayani P ___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
[avr-gcc-list] no rule to make elf - error
Hello all, I am using avr-gcc (WinAVR 20090313) 4.3.2 with PN - version v2.0.8.718-basie. When I create a project and try to compile a very simple file, I am getting make.exe: *** No rule to make target `test.c.elf', needed by `elf'. Stop. Can some one point ahy I am getting this help? I have created the project using the PN File-new-project etc. I created and stored the Makefile in the project duirectory using Mfile. Thanks for your support. Nayani P ___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
[avr-gcc-list] Xmega support
Hello all, I have just started testing an XMEGA64 chip and I find a peculiar problem when I use sprintf. Following are the environment/specs: XMEGA64 running at 32MHz (using the internal freq generator) USART on PC0, operating at 115K BAUD. One timer in port D being used in compare capture mode. The program is a very simple one. At start, 8000H, (let me call this CCAVAL) is written into the compare register and this generates a frequency on pin OC0A. Usart receive is interrupt driven. When a new value for CCAVAL is sent through the serial port, main loop converts the value and writes to the compare register. This should change the frequency of the square wave on OC0A. To test the vaule being written to ccaval is being sent back to PC and this is where the peculiar problem is noticed. We are using sprintf function to conver the binary value of ccaval and then sending it PC through another function. When we use a global buffer in sprintf, the program behaves erratically. The timer stops for some time and then starts with the new value. However if use a local buffer in sprintf then everything works fine. Example code given below char globalbuf[20]; sprintf (globalbuf,%05u\r\n,ccaval); // problem. globalbuf defined outside main. sprintf (localbuf,%05u\r\n, ccaval); // no problem. everything works fine. Can some one point me to the mistake we are making? or is this a problem with GCC? Thank you. Regards Nayani P ___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
Re: [avr-gcc-list] Xmega support
Hello All, Just not to enter a wrong address, I copy the address or clear the message and write new one. My apologies for inadvertently doing so. I am creating a new thread with a different heading. Thanks. Nayani --- On Thu, 8/20/09, David Kelly dke...@hiwaay.net wrote: From: David Kelly dke...@hiwaay.net Subject: Re: [avr-gcc-list] Xmega support To: Steven Michalske smichal...@gmail.com Cc: avr-gcc-list avr-gcc-list@nongnu.org Date: Thursday, August 20, 2009, 3:11 AM On Wed, Aug 19, 2009 at 02:23:10PM -0700, Steven Michalske wrote: This message got buried in a thread, because you used a reply to a previous message from the list. It's poor manners to hijack threads, and can cause some users not to reply. Same applies to top-post without trim. -- David Kelly N4HHE, dke...@hiwaay.net Whom computers would destroy, they must first drive mad. ___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list ___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
[avr-gcc-list] XMEAG64 code problem
Hello All, I am facing a peculiar problem with XMEGA64 code. When I use a global buffer in sprintf, the board appears to reset, but the initial values (which are changed before a call to sprintf) are not getting effected. If I use a local buffer (same size) there is no problem. Can some one point out what could be wrong? Thanks. Nayani ___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
[avr-gcc-list] Larger than 64K memory sections
Hello all, I am using a 4MB flash memory with my Mega64. I would like to create a memory section for the entire 4MB. Is it possible? If yes, how can this be done in the makefile? Thank you very much for your time. Regards, Nayani ___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
[avr-gcc-list] Problem allocating memory in xflash
Hello all, I have created an external flash memory section in the makefile thus LDFLAGS += -Wl,--section-start,.exflash=0x85 and named (defined) this section as XFLASH. I have a structure prclkp of size 32 bytes. When I define struct prclkp XFLASH PLULOC1[1023]; No error is reported, whereas struct prclkp XFLASH PLULOC1[1024]; generates an error - size of array too large If the size of the section is 64K, then the above i well within the limit but still the error is popping up. Has this anything to do with sign? Please advice. Thank you. Regards, Nayani ___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
Re: [avr-gcc-list] Re: Larger than 64K memory sections
David Kelly wrote: You are right that we know nothing about the application in question - details here would make it much easier to give recommendations. Hello all, I mentioned 4MB flash as it is the HW spec. This 4MB gets filled over a period of time. Details of application - I have data packets each 32 bytes in size and we have accommodate 2000 of these (predefined). This I plan to put in a part of the 4MB Flash. Rest of the memory will be used for storing records comprising of these data packets with data and time etc. The records will be deleted from time to time but the data packets will remain. It is possible to use a long int as an address pointer from the start of the available memory (after the data packets) and store records. I still curious to know how one can create a section larger than 64K. Nayani ___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
Re: [avr-gcc-list] Problem allocating memory in xflash
From: Joerg Wunsch j...@uriah.heep.sax.de Sure, it depends from sizeof(int). My array size is 32K bytes and the section is supposed to be 64K right? and is not the built-in limit of a section 64K? Thanks. Regards Nayani ___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
Re: [avr-gcc-list] Problem allocating memory in xflash
From: Jan Waclawek konf...@efton.sk Sure, it depends from sizeof(int). Hummm, for me, the relationship is not quite sure. Can you explain that in more detail, please? I tried to allocate 32K bytes of memory. I am not sure if this is a problem of user defined sections. Nayani ___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
Re: [avr-gcc-list] Re: Larger than 64K memory sections
From: David Kelly dke...@hiwaay.net 4 million bytes or bits? Most FLASH devices are sized by the bit. It is 4M Bytes. No matter what you do you won't be able to say *MyUInt16Ptr = 0x1234; you will have to write a routine and use it something like this: u16_value = 0x1234; result = Write4MBFlash( (uint32_t)MyUint16Ptr, sizeof(uint16_t), u16_value ); One advantage I found, using name spaces (sections) is, generating a hex file for initialised data, which can be downloaded through serial port. All the external SPI FLASH devices I have used are paged. One read/writes to a RAM buffer in the device then flush that buffer to a page in FLASH. IIRC the Atmel device I last used had 264 byte pages which served to complicate addressing if one insisted on using all 264 bytes. Believe the designer's intent was that one use 256 bytes as a sector and the other 8 bytes for tracking usage, even linking to previous sector and next sector for a form of filesystem. Never thought of this (using the extra 8 bytes for tracking/linking to other sectors) Atmel had a very useful appnote containing C routines for access to their DataFlash parts which helped a lot. I felt the need to heavily edit it for style and naming convention. Rearranged a bit, and deleted a lot that I didn't use. But it was a very good start. Will check Atmel's site . Thank you. Nayani ___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
Re: [avr-gcc-list] including default eeprom values in flash memory
From: Michael Clift mich...@clift.com.au Hi, I am using winavr, and would like to include the default eeprom values (normally output to .eep) in flash memory. I want to do this so that my application can easily default the eeprom. Hello, EEPROM data in FLASH memory? then the easy way is to use the PGM space attribute to the variables you want in flash. Nayani ___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
Re: [avr-gcc-list] PLease help wtih a correct code
--- On Sun, 2/28/10, Jeano Kalawa doki...@yahoo.fr wrote: From: Jeano Kalawa doki...@yahoo.fr I am working with my final prosject at University. I work with a SHT 75 sensirion sensor to measure temperature and humidity. I use an ATmega 32 controller and have to send data to a PC-skjerme via UART. I do try to use the sample code from sensirion ,but it does not work. Hello Jeano, Seen the PDF. The code looks mangled!!! Initial comment says the code is for 8051 but includes show at89s53.h. Again intrins.h is not part of GCC. Nayani ___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
[avr-gcc-list] Peculiar code size problem
Hi all, I am working on an ATMEGA8. Since my code was getting close to 8K, I thought I would tweak the code. I have a function listed below void pulse_en (void) { set_EN; // Set EN _delay_loop_1 (255); clr_EN; // clear EN _delay_loop_1 (255); } Since the delay after the clr instruction had no meaning, I commented the line and compiled the code hoping I would save a couple of bytes. But to my surprise the code size increased to 7172 bytes compared to 7148 bytes with the function call in place. I looked at the list file and found that the function gets shifted to a different location with and without the function call. Here are the list file snippets With the call in place: 351 pulse_en: 352 .LFB23: 353 .LM47: 354 /* prologue: function */ 355 /* frame size = 0 */ 356 .LM48: 357 0128 C29A sbi 56-32,2 358 .LBB80: 359 .LBB81: 360 .LM49: 361 012a 8FEF ldi r24,lo8(-1) 362 012c 982F mov r25,r24 363 .LVL17: 364 /* #APP */ 365 ; 83 c:/winavr-20100110/lib/gcc/../../avr/include/util/delay_basic.h 1 366 012e 9A95 1: dec r25 367 0130 01F4 brne 1b 368 ; 0 2 369 /* #NOAPP */ 370 .LBE81: 371 .LBE80: 372 .LM50: 373 0132 C298 cbi 56-32,2 374 .LBB82: 375 .LBB83: 376 .LM51: 377 /* #APP */ 378 ; 83 c:/winavr-20100110/lib/gcc/../../avr/include/util/delay_basic.h 1 379 0134 8A95 1: dec r24 380 0136 01F4 brne 1b 381 ; 0 2 382 .LVL18: 383 /* epilogue start */ 384 /* #NOAPP */ 385 .LBE83: 386 .LBE82: 387 .LM52: 388 0138 0895 ret Without the call: 621 .LFE21: 623 .globalpulse_en 625 pulse_en: 626 .LFB23: 627 .LM87: 628 /* prologue: function */ 629 /* frame size = 0 */ 630 .LM88: 631 01c2 C29A sbi 56-32,2 632 .LBB146: 633 .LBB147: 634 .LM89: 635 01c4 8FEF ldi r24,lo8(-1) 636 .LVL36: 637 /* #APP */ 638 ; 83 c:/winavr-20100110/lib/gcc/../../avr/include/util/delay_basic.h 1 639 01c6 8A95 1: dec r24 640 01c8 01F4 brne 1b 641 ; 0 2 642 /* #NOAPP */ 643 .LBE147: 644 .LBE146: 645 .LM90: 646 01ca C298 cbi 56-32,2 647 /* epilogue start */ 648 .LM91: 649 01cc 0895 ret Will some one please let me know why this is happening? If such is the case, perhaps extra code is being generated for other function too. I am using: avr-gcc (WinAVR 20100110) 4.3.3 Thank you for your time. Regards, Nayani___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org https://lists.nongnu.org/mailman/listinfo/avr-gcc-list
Re: [avr-gcc-list] Peculiar code size problem
Dear Eric, Yes indeed, the total code bloated, though the function size actually reduced. Perhaps my first post was not clear on this point. I can mail you the entire code, should you wish to see it. Please let me know so I can do the needful. I am wondering as to what this cause is and any method to detect it or at the least prevent code bloat. Thank you for your time. Regards, Nayani From: Weddington, Eric eric.wedding...@atmel.com Sent: Monday, March 19, 2012 1:44 AM Subject: RE: [avr-gcc-list] Peculiar code size problem Your function pulse_en reduced in size as expected. However, your overall code size increased. Without access to the rest of your code, we cannot tell what causes the overall size increase. Eric___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org https://lists.nongnu.org/mailman/listinfo/avr-gcc-list
Re: [avr-gcc-list] Peculiar code size problem
Hello David, Thank you for your reply. Yes this seem to be the problem Current working program with delay call size turned out to be 7092 bytes. With your suggestion of noinlie attribute the code is now 7086 bytes. Thank you for your help. This seems to have solved the problem and also answered my query. This may also help others who have similar problem. Thanks once again. Regards, Nayani From: David A. Lyons dly...@lyons42.com To: Parthasaradhi Nayani partha_nay...@yahoo.com Cc: avr-gcc-list@nongnu.org avr-gcc-list@nongnu.org Sent: Monday, March 19, 2012 5:46 AM Subject: Re: [avr-gcc-list] Peculiar code size problem The smaller size might be making the compiler decide to inline the function at some call sites where it didn't before. You could experiment with -fno-inline-small-functions (compiler option) and/or __attribute__((noinline)) on your function declaration: void pulse_en (void) __attribute__((noinline)); void pulse_en (void) { ... } Cheers, --Dave___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org https://lists.nongnu.org/mailman/listinfo/avr-gcc-list
[avr-gcc-list] Parm to application
Hello all, I have a boot loader and an application on a Mega168. As boot loader and application are two different entities, is there any way the boot loader can pass a parameter to application code? Would like something like main (int argc, char *argv[]). Any suggestions please? Thank you. Regards, Nayani ___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org https://lists.nongnu.org/mailman/listinfo/avr-gcc-list
Re: [avr-gcc-list] Parm to application
From: Georg-Johann Lay a...@gjlay.de Reserve a piece of RAM that does not depend on how the application is compiled, for example at the start of .data (bump .data to a later location) or at the top of the stack (initialize SP to RAMEND-offset). In the boot loader, write the data to that reserved space. It should also be okay to call main from .init8 by hand if you prefer C, e.g. main (argc, argv); _exit (0); or main (argc, argv, env); _exit (0); Hello Johann, Thank you for your reply. Yes this was one approach that is possible, but it is pretty much dependent on absolute address. Passing arguments to main is actually not possible in a bare bone system right? or is there any method?I would actually prefer to call application main with parameters from boot section. Regards Nayani___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org https://lists.nongnu.org/mailman/listinfo/avr-gcc-list
Re: [avr-gcc-list] Parm to application
From: Georg-Johann Lay a...@gjlay.de With int x __attribute__((section (.bootdata))); you can use x in the known way, it's only about locating .bootdata to whatever location you deem appropriate. Read the linker manual. This appears to be the only best way!!! This means I create a section, say .bootdata with some address in the boot loader. Create exactly the same section with the same address in the actual application section. Since the boot loader starts first, it writes whatever data to be passed into this section and when application gets executed, it reads this section. Am I right? One point to consider - boot loader is somewhat a permanent fixture in flash, whereas application(s) can keep changing or updated. Should the compiler version be same for both? will the ordering of variables change with versions? If this remains same, then the above approach is best as of now, else the same compiler has to be used for future updates of application. I would actually prefer to call application main with parameters from boot section. Calling main from boot does not sound sane. How do you know the address of main? How do you run startup code to initialize .data and .bss, setup SP, call constructors, etc.? How do you reset the hardware like communication I/O? There are two issues - 1. I/Os can be initialized in the boot section as the boot loader will be specific to the target board. 2. SP setup etc., will have to be done afresh in the application portion. When I mentioned calling main, it is actually calling application startup (00 address). This is not possible any way (I guess). Thank you. Regards Nayani___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org https://lists.nongnu.org/mailman/listinfo/avr-gcc-list
[avr-gcc-list] External 256K FLASH - memory pointer
Hello all, I have an external FLASH (serial) of size 256K. I would like to create a memory section for this memory and have pointers (more than 16 bits) to this memory. Can some one help me please? I am sorry if such a topic has already been dealt with, as my googling did not yield the desired result(s). I await your suggestions/help and thank you for your time. Regards, Partha___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org https://lists.nongnu.org/mailman/listinfo/avr-gcc-list
Re: [avr-gcc-list] External 256K FLASH - memory pointer
From: Joerg Wunsch j...@uriah.heep.sax.de To: avr-gcc-list@nongnu.org Sent: Tuesday, September 18, 2012 11:21 AM What's the point? A pointer is just a 32-bit (or perhaps 24-bit, in recent AVR-GCC versions) number. Normally, the point of using a pointer is that the compiler arranges for you to dereference the pointer automatically, but this memory being external, not accessible by normal CPU instructions, this cannot work anyway. Consequently, you can use the respective integer numbers by itself (perhaps through some kind of typedef that hints them being memory addresses). Thanks for the response. Basically the requirement is to use external serial FLASH memory. We wanted large pointer for two things 1. To declare a section and assign variable names which is better than using absolute addresses. This is possible. 2. Pass the address to functions which do the reading and writing the memory. Given below is an example function prototype we would like to have void ReadXFlashBlock (unsigned char *destptr, unsigned char *sourceaddr, unsigned int noofbytes); In the above destptr is not an issue but sourceaddr is. If a 32 bit pointer can be somehow declared then this will be pretty elegant. If this is not possible then the only alternative would be to change the function parameters as shown below which is not really elegant. void ReadXFlashBlock (unsigned char *destptr, long sourceaddr, unsigned int noofbytes); The calling program must treat this long variable as a pointer rather than long itself. Nayani___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org https://lists.nongnu.org/mailman/listinfo/avr-gcc-list
Re: [avr-gcc-list] External 256K FLASH - memory pointer
Hello Richard, Thanks a lot for your suggestion. Yes we can and it has already been suggested: Define Your own abstract data type with an underlying 32 bit integer. You can even overload all operators for it to achieve full pointer semantics. But I would not go so far and overload the dereferencing operator for readability reasons. The signature for Your read function would then look like: void ReadXFlashBlock (unsigned char* dst, FlashAddress src, unsigned int size); If templates are Your friends, You can go further and add the value type to Your abstract address type. This way You avoid ugly casting orgies everywhere in Your code and You can not mess up integers, internal memory pointers and external flash addresses. Ok, these are features of avr-g++, but why not? I do not know if there will be any code over head due to C++. Unfortunately my forte is 'C'. Can I trouble you for some examples/sample code please? Thank you once again. Regards Nayani___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org https://lists.nongnu.org/mailman/listinfo/avr-gcc-list
Re: [avr-gcc-list] avr-gcc 4.7 for Windows
From:Georg-Johann Lay g...@gcc.gnu.org To: avr-gcc-list@nongnu.org Subject: [avr-gcc-list] avr-gcc 4.7 for Windows GCC 4.7 has just been released, and I decided to provide a MinGW32 build of avr-gcc-4.7.2. Many people feel uncomfortable with building the tools to run under MS Windows, so here they are. The package is supplied as a ZIP archive avr-gcc-4.7.2-mingw32.zip. Unpack the ZIP file to your favorite a location; it will inflate to a directory called avr-gcc-4.7.2-mingw32. The binaries are located in avr-gcc-4.7.2-mingw32\bin To use the compiler, call avr-gcc-4.7.2-mingw32\bin\avr-gcc.exe directly or add the avr-gcc-4.7.2-mingw32\bin to your PATH environment variable. Most notable changes in 4.7.2 compared to 4.7.1 is the support of a new configure option --with-avrlibc that implements a better integration of AVR-Libc with avr-gcc: AVR-Libc supplies optimized versions of support functions that traditionally live in libgcc. --with-avrlibc makes sure that always the optimized versions from AVR-Libc are used. Hi, Thanks for the post. I noticed some peculiarities in the latest version specially regard to FLASH section. The compiler is throwing out errors when PROGMEM attribute is provided. unsigned char PROGMEM P_gu8_nlup[] dvr.c:205:40: error: variable 'P_gu8_nlup' must be const in order to be put into read-only section by means of '__attribute__((progmem))' The error clears if 'const' is placed before 'PROGMEM'. unsigned char const PROGMEM P_gu8_nlup[] Wondering whether there is any change in the latest version. Thank you. Nayani ___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org https://lists.nongnu.org/mailman/listinfo/avr-gcc-list
Re: [avr-gcc-list] gcc-avr 4.9.2 -Os messes with interrupt vectors
Hi, "I do *not* want the ISR to be called". I guess you do not want the interrupt to be enabled. If you do not start the timer (as the interrupt is timer related) this interrupt will never occur. If you are using the timer for something else and need the timer running, then you need not explicitly enable timer overflow interrupt (see TIMSK register bits). In the while loop, you are always setting the port bit which I guess is connected to the LED and the LED will glow when this bit is 1. Suggest toggling the LED through a while loop with delays (large enough to be able to see LED flashing) inserted. Regards, Parthasaradhi Hyderabad On Sunday, May 8, 2016 3:06 PM, "a...@tuta.io"wrote: Thank you for your instant response. I am sorry if I was unclear about that: I do *not* want the ISR to be called. The LED should turn on because I enable it in main(), however, the uC goes straight to the ISR! For example, if I set the LED to high in the ISR and set it to low in main(), it will be set to high and the LED will turn on when I flash it. Even though I used cli()! This behavior appears to depend on -Os, so I guess I am either using the tools incorrectly, or there is a bug in the optimization code. 8. Mai 2016 11:22 von partha_nay...@yahoo.com: First off, you are disabling global interrupts (cli ()). You need to enable them (sei ()). I presume you are toggling the LED in ISR, if so the LED will not toggle as interrupts are disabled. Regards, Parthasaradhi Hyderabad On Sunday, May 8, 2016 2:40 PM, "a...@tuta.io" wrote: Hello, I have been working on a project for some time and at some point, everything just stopped working. It appears that as soon as I include an ISR in my C code, the main function won't even be called anymore. I reduced my code to this: #include #include int main (void) { cli(); DDRB = 0xff; while(1) PORTB |= (1 << PB5); return 0; } ISR(TIMER0_OVF_vect) {} But the LED just won't turn on. The strange thing is: If I remove the ISR at the bottom without changing anything else, even keeping the include, everything works. If I remove the -Os option from gcc but keep the ISR, everything works. I use these commands to compile, link and flash it: F_CPU=1600L avr-gcc -Wall -DF_CPU=$F_CPU -c -mmcu=atmega168 -Os main.c -o main.o avr-ld -mavr5 -o led-test.elf main.o avr-objcopy -O ihex led-test.elf led-test.hex sudo avrdude -c avrisp2 -p atmega168 -P usb -b 57600 -U flash:w:led-test.hex I am quite new to the avr tools so I might just have made a silly mistake, so I would appreciate any tips! Thank you! LSB: Distributor ID: Ubuntu Description: Ubuntu 16.04 LTS Release: 16.04 Codename: xenial Output of avr-gcc -v: Using built-in specs. Reading specs from /usr/lib/gcc/avr/4.9.2/device-specs/specs-avr2 COLLECT_GCC=avr-gcc COLLECT_LTO_WRAPPER=/usr/lib/gcc/avr/4.9.2/lto-wrapper Target: avr Configured with: ../src/configure -v --enable-languages=c,c++ --prefix=/usr/lib --infodir=/usr/share/info --mandir=/usr/share/man --bindir=/usr/bin --libexecdir=/usr/lib --libdir=/usr/lib --enable-shared --with-system-zlib --enable-long-long --enable-nls --without-included-gettext --disable-libssp --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=avr CFLAGS='-g -O2 -fstack-protector-strong -Wformat ' CPPFLAGS=-D_FORTIFY_SOURCE=2 CXXFLAGS='-g -O2 -fstack-protector-strong -Wformat ' FCFLAGS='-g -O2 -fstack-protector-strong' FFLAGS='-g -O2 -fstack-protector-strong' GCJFLAGS='-g -O2 -fstack-protector-strong' LDFLAGS='-Wl,-Bsymbolic-functions -Wl,-z,relro' OBJCFLAGS='-g -O2 -fstack-protector-strong -Wformat ' OBJCXXFLAGS='-g -O2 -fstack-protector-strong -Wformat ' Thread model: single gcc version 4.9.2 (GCC) ___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org https://lists.nongnu.org/mailman/listinfo/avr-gcc-list ___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org https://lists.nongnu.org/mailman/listinfo/avr-gcc-list