#include <intrins.h> void test_nop (void) { P1 = 0xFF; _nop_ (); /* delay for hardware */ _nop_ (); _nop_ (); P1 = 0x00; }
how i can do this function by codevisionavr ? is it possible?
#include <intrins.h> void test_nop (void) { P1 = 0xFF; _nop_ (); /* delay for hardware */ _nop_ (); _nop_ (); P1 = 0x00; }
how i can do this function by codevisionavr ? is it possible?
What does the CodeVision documentation tell you ... ?
What is the source of this code?
My guess is it sets a port bit (p1 = 0xFF;)
then delay's using nop's.
then clears a port bit (p1=0;)
An oscilloscope or logic analyzer connected to that port pin would show a short blip.
A similar function in any c compiler should be trivial if you know your target cpu and compiler.
Jim
In CV, you would use inline assembler. (if you investigate intrins.h you will also probably find macros for inline assembler)
A single-line inline assembler in CV is explained in the documentation. Example of use:
for (looper = 0; looper < ADC_CHANNELS; looper++) { #asm("cli"); adc_total[looper] += adc_raw[looper]; #asm("sei"); }
In your case you would probably want #asm("nop");
If you care to, you could wrap that in a #define called _nop_ or whatever you like.
Looks like 8051 and Keil C51 ...
i want to work with atmega32 and codevision error while running this code
error while running this code
I presume you mean that you get errors when you build this code?
This is bound to be the case - because the code is for an entirely different type of chip (an 8051, not an AVR), and relies upon the proprietary extensions of an entirely different compiler (Keil, not CodeVision)!!
i want to work with atmega32 and codevision error while running this code
Why do you think some code for 8051 is in any way relevant to the AVR?
Maybe this explains why the OP did not seem to grasp your point (repeated by others) in his/her other thread about reading make & model from a chip ...
EDIT
Link: https://www.avrfreaks.net/comment...
#include <intrins.h> void test_nop (void) { P1 = 0xFF; _nop_ (); /* delay for hardware */ _nop_ (); _nop_ (); P1 = 0x00; }
how i can do this function by codevisionavr ? is it possible?
P1 = 0xFF; P1 = 0xFF; /* repeat for as long as you want the pulse hi */ P1 = 0xFF; /* assuming P1 declared 'volatile', these won't be optimized out */ P1 = 0x00;
What if P1 in an 8051 is like PINB in a Mega 328? ;-)
What if P1 in an 8051 is like PINB in a Mega 328? ;-)