CodeVision AVR Help

Status
Not open for further replies.

hitusharpatil

New Member
Can anyone tell me how "printf" statement works in CodeVision AVR and after compling Where Can I see output

OR please tell me Why "printf" is use in Codevision AVR
 
hitusharpatil said:
Can anyone tell me how "printf" statement works in CodeVision AVR and after compling Where Can I see output

OR please tell me Why "printf" is use in Codevision AVR

I'm not sure about Codevisions printf function, but in general printf is formated printing. It uses putc, which directs the output stream to whatever you want. If your putc function is directed at an LCD, this is where it will show up. If it is directed at the serial port then sent to a PC, you can view the stream with a terminal program, etc.

Here is a simple example of a printf function with no strings and no floating point:
Code:
/*-----------------28.08.99 22:49-------------------
 *   Simple printf function (no fp, and strings)
 *--------------------------------------------------*/
int printf(const char *format, ...) {
  static const char hex[] = "0123456789ABCDEF";
  char format_flag;
  unsigned int u_val, div_val, base;
  char *ptr;
  va_list ap;

  va_start (ap, format);
  for (;;) {
     while ((format_flag = *format++) != '%') {      // Until '%' or '\0'
       if (!format_flag) {
         va_end (ap);
         return (0);
       }
       lcd_putch (format_flag);
     }

     switch (format_flag = *format++) {
       case 'c': format_flag = va_arg(ap,int);
       default:  lcd_putch(format_flag); continue;

       case 'd': base = 10; div_val = 10000; goto CONVERSION_LOOP;
       case 'x': base = 16; div_val = 0x10;

       CONVERSION_LOOP:
       u_val = va_arg(ap,int);
       if (format_flag == 'd') {
         if (((int)u_val) < 0) {
           u_val = - u_val;
           lcd_putch ('-');
         }
         while (div_val > 1 && div_val > u_val) div_val /= 10;
       }
       do {
         lcd_putch (hex[u_val / div_val]);
         u_val %= div_val;
         div_val /= base;
       } while (div_val);
    }
 

Can you please tell me how can I see output of above program on PC?
What modifiactions should I do in the above code?
 
You don't need to add the function to your code; it is an example of how printf works. To direct your output to a PC, then write yourself a PC_putc() function which will direct its output to a serial stream using a UART if you have one on your chip. Which chip are you using?
I will try to find out more about codevision, if I can.
 

I am using Atmega32. Do I need to burn the cip and then see the output?
 
Looks like codevision has a wizard to set up a project to do this. I found this info on the IDE:

I downloaded the manual; I'll tell you more in a few minutes.
 
I am using Atmega32. Do I need to burn the cip and then see the output?

Yes, you will have to do this in order for it to run (unless you are doing the project in simulation first.)
 
BeeBop said:
Yes, you will have to do this in order for it to run (unless you are doing the project in simulation first.)

Suppose I burnt the program on chip now I want to see the output on PC.
So how can I interface Chip with PC to see output? What steps do i need to follow?
 

Now things are too much complicaetd for my Project. I have a project form net but thing is that it is very difficult for me to proceed. will you please guide me?
 
Well, I haven't done much of anything with AVR, but can try...

What project are you working on?
 
BeeBop said:
Well, I haven't done much of anything with AVR, but can try...

What project are you working on?

I am working on "Voice command Recognition System" using Atmega32 to glow LED at output Port. I have similar project with code but as I am new in this field I cant proceed properly.
 
Last edited:
I have a quick question regarding CodeVisionAVR. I have an electronic project going on and I need to program a certain hex-file to AT90S2313-chip by using **broken link removed**-board and CodeVisionAVR. I've programmed and practised with that same equipments and c-files, but now I'd need to program a hex-file, instead of c-file, to the chip with CodeVision and I have no idea how. I'm a total beginner at programming so any help would be highly appreciated. Thanks
 

I'm not an AVR expert, or a CodeVision one either. You will need a programmer of some sort... and programming software to run it. Do you have these?

If not you could try PonyProg. Look for a circuit diagram and the software download here:
 
I'm not an AVR expert, or a CodeVision one either. You will need a programmer of some sort... and programming software to run it. Do you have these?

If not you could try PonyProg. Look for a circuit diagram and the software download here:
I have EXB2313-board as a programmer like I said. I have already tried with PonyProg, and it worked with hex-files easily but somehow it wasn't able to put the hex-file to the chip, if I remember correctly it said something about device missing/unknown etc.
 

I didn't realize it was a programmer as well. Your link led to a photo of the board, not the place you got it, which would have included some useful information.

If that is your error message, then PonyProg didn't work. Then again, your text isn't very clear, I gather English is not your first language? How do you mean 'it worked with hex-files easily?' Probably it isn't configured correctly for your board. Can you post a link to the board, not to a photo of the board? There is no way to tell how that EXB2313 is made with a photo.

Never mind the link, I found the manual for your EXB2313. According to the manual, you should be able to download the hex file to the board directly from codeVision. Have you tried this?
 
Last edited:
Indeed English isn't my native language.

By 'it worked with hex-files easily?' I meant that PonyProg opens hex-files easily when I just selected Open from PonyProg and selected the hex-file. But in CodeVision I can't open the hex-file so it could be programmed into the chip. If I open the hex-file to CV, it goes to Other Files, like the 'thermlcd.asm' in **broken link removed** on left. And if something is in that Other Files -section in CodeVision, it can't be programmed in to the chip. It should be in the Project: *something* -section, but I can't open it in to that section, it always goes to Other Files.
 
Hi - To program the chip you will need to make/use the programming lead that connects the programming port to the parallel port of your PC. This emulates the Dontronics DT006 programmer which has to be selected on CvAvr programmer settings. The serial port on your EXB2313 cannot be used for programming. (It could be used as a bootloader but my advice is do not even think about it yet).
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…