, >>>

ChipNews

2003: 
1, 2, 3, 4, 5, 6, 7, 8, 9, 10
2002: 
1, 5, 6, 7, 8, 9
2001: 
1, 2, 3, 4, 5, 6, 7, 8, 9, 10
2000: 
1, 2, 3, 4, 5, 6, 7, 8, 9, 10
1999: 
1, 2, 3, 4, 5, 6, 7, 8, 9, 10

ChipNews

Новости строительства

827:

827 0688759652

:

- . , , " " " ", .

2963-2 (RUS) . :

2963-2

II ... 372:

!

PIC18. 2

. , .

PIC18. 2

"-" - θ . , . Ÿ .

MICROCHIP MPLAB C18: , , ( ). . MPLAB C PIC16 Microchip . , PIC18 , MPLAB C.

HI-TECH PICC-18 COMPILER: HI-TECH PIC16, , PIC18 . ANSI HT-SOFT , , PIC16 PIC18 . (bugfixes.txt) , , . , Linux.

CCS C: , - , ĸ CCS: http://www.ccsinfo.com/compare.html. , CCS C , . CCS C #asm/#endasm.

IAR C/EC++ Compiler for Microchip PIC18: , ++ (Embed-ded C++). , () ++ ++ PIC18. "-" , .

. ( ) LIBC MATH. , , . , , ظ , , ( ) .

, MPLAB C18 libc . - , , . , , CAN- MCP2510. .

HT PICC18 . , -, . HITIDE .

, S , HT-PICC. ( build-in ). - , . CCS C . , CCS, , .

IAR C/EC++ libc , ++. libstdc++ ( ), dlib . IAR . , , .

Microchip , : RS232, CAN, I2C , - . MPLAB C18 PIC18. , , , . , . CCS C , . HT-PICC , HITIDE code snippets, .

, (, ) .

ĸ MPLAB C18, IAR PIC18, HT PIC18 S , , PIC18. , . , ̸ . ޸ . - , ( ) .

, MPLAB.

, MPLAB ( http://www.microchip.com/download/tools/picmicro/code/third/51234a.pdf CD-ROM), Project->Install Language Tool -, , . HI-TECH picc18.exe ( , ). , Project->Edit Project->Node Properties Language Tool, , Add Node . HITIDE HT-PICC18 .

MPLAB C18 , (*.lkr), (Add Node) , h- . , MPLAB C18 ( , MPLAB 5.), .

IAR C MPLAB , IAR, C-SPY.

CCS MPLAB, S MPLAB .

char , MPLAB, , SFR. (printf). , #include <>. :

  • #include IAR C
  • #include HT-PICC18
  • #include MPLAB-C18
  • #include <18F452.h>

CCS C PORTB=.. output_b().

ĸ :

1
long fac(long x)
{
if (x<=1) return 1;
else return x*fac(x-1);
}
main()
{
long i;
i=fac(5);
PORTB=i;
}

CCS HT-SOFT, . , CCS C HT-SOFT C , , :). , PIC18 - PIC16. , IAR MPLAB-C18 , (120). ( ). , IAR MPLAB-C18, , (, TCP/IP, ) PIC18.

.

2
#define MSG_LEN 23
#define MAX_TX 3
struct rx_data
{
  char bit_count;
  unsigned track : 1;
  unsigned store_bc : 7;
  long buf_h;
  long buf_l;
};
long cof[]={0xf8dd4258,0xf9a42bb0, 0xf930b51c,0xfa2561cc};
struct rx_data db[MAX_TX];
char h_weight(long word)
{
  char l;
  char sum=0;
  for(l=0;l {
  sum+=(0x8000000l&word?1:0);
  word<<=1;
  }
  return sum;
}
void main()
{
  char crls,t;
  or(t=0;t db[t].buf_h=cof[t];
  crls=0;
  for(t=0;t crls+=h_weight(db[t].buf_h^cof[t])-16;
  //to disable removing redundant code
  PORTB=crls;
}

, HT-PICC18 - crls+=h_weight(db[t].buf_h^cof[t])-16; , HT-PICC18 ( PIC16 ). .

. ( ) ( ) -, . , , , PORTB= HT-PICC18 - HITIDE, MPLAB C18 MPLAB 6.xx, c CCS C - MPLAB 5.xx, IAR - "" . , , HITIDE: . , . , , . , ޸ IAR , - . ĸ IAR C/EC++ 2 , ޸.

, , . , ߸ , - . , , . , S - , HT-PICC / , MPLAB C18 IAR , ̸ (branch opti-mization, common subexpresion optimi-zation ..), . IAR ICCPIC18 MPLAB-C18 , .

, MPLAB-C18 IAR ICCPIC18.

IAR C - "" . Common-subexpr elimina-tion - , , function inlining - ( , ), code moution - ( ), loop unrolling - ( ޸ ). . 2 2. , .

2. a IAR ICCPI18

(none) (high) (high) (high) +
291 226 211 196
349 302 349 298

3. MPLAB C18

(-O-) (default )
634 (far ) 602 (far )
595 589
888 589

: static overlay stack. static overlay , , - ++ ( ). RAM - clib , ANSI, ++.

MPLAB C18 Micro-chip http://www.microchip.com/1010/pline/tools/picmicro/code/mplab18/index.htm. MPLAB CXX Users and Reference Guide Ad-dendum (51255b.pdf). - MPLAB C18 Optimization Tips (optimize.pdf). , . , IAR, , ( - ). , . , .. , , (mcc18.exe | more). MPLAB C18, small- near-.

, MPLAB-C18 . , - (static overlay) , (far), . , far- , , .

libc.

.

3
#include
#include
#include
char a[20];
main()
{
  int i,j;
  char b[20];
  for(;;)
  {
  for(j=0;j<10;j++)
  {
  i=rand()&0xfff;
  sprintf(b,%x,i);
  strcpy(a,b);
  }
  for(i=0;i<10;i++)
  ~PORTB=a[i];
  }
}

, . , MPLAB-C18 - . sprintf . . 4.

4. , . - a , - e PORTB ( )

2 3 4 5
IAR 196/1606 1310/89888 (clib) 1971/84689 250/32749
MPLAB C18 589/3360 586/74969
HT-PICC18 1121/33271 1702/380713 (32bit)
1444/356060 (24bit)
198/74975
CCS C 229/4223 302/12455 2478/483958 182/69797

5. N e ++ IAR. - a , - e PORTB ( )

clib C dlib C++
250/32749 439/49740 1345/50824

. .

4
#include
main()
{
  float x,y;
  int i;
  for(i=0,x=0.1,y=0;i<12;i++,x+=0.03)
  {
  y+=sin(x)*cos(x)/log(1+x*3.3);
  }
  PORTB=(int)(10*y);
}

- MPLAB-C18 .

͸ , . . 4.

5
#define GEN_POLY 0x81
#define POLY_MASK 0x400
#define STN 4
int next(unsigned int * state)
{
  int ret;
  ret=*state & 0x1;
  *state&=~POLY_MASK;
  if (ret) *state^=(GEN_POLY);
  *state>>=1;
  return ret;
}
main()
{
  unsigned int st[STN];
  int i,j,t;
  for(i=0;i {
  st[i]=POLY_MASK-1;
  }
  for(i=0;i<20;i++)
  {
  for(j=0;j ~~for(t=0;t<=j;t++)
  next(st+j);
  }
  for(i=0;i {
  PORTB=st[i];
  }
}

, IAR IAR EC++ . , ++ . 5 ++ .

6
const unsigned int GEN_POLY=0x81;
const unsigned int POLY_MASK=0x400;
const unsigned int STN=4;
class poly {
unsigned int state;
public:
  poly() {state=POLY_MASK-1;};
  int next()
  {
  int ret;
  ret=state & 0x1;
  state&=~POLY_MASK;
  if (ret) state^=(GEN_POLY);
  state>>=1;
  return ret;
  };
  int get_state() {return state;};
};
extern C int main(void)
{
  poly st[STN];
  int i;
  for(i=0;i<20;i++)
  {
  for(int j=0;j ~~for(int t=0;t<=j;t++)
  st[j].next();
  }
]   for(i=0;i {
  PORTB=st[i].get_state();
  }
}

, IAR EW 2.11 EC++ (, - ).

ĸ , . IAR C/EC++ - - . . ޸ . . . , ++- IAR, , - ( ). , ++ PIC18.

MPLAB-C18 - MPLAB-C - . , "-". , - . . . - . Ӹ - .

HT-PICC18 - (, - HT-PICC). - - . - - . RTOS PIC. . , .

CCS C18 - . PIC-. . , . - ( MPLAB) . , HT-PICC18, -. ޸ , .

"" , MPLAB C18 CCS C. CAN (PIC18F458/448/258/248 CAN-). , , . , PIC18 ( PIC18 ), , .

. / . .

PIC18 . - ( 1 , ) - ( ) , . , ( -, ), .





PatrickSkype ...

, , . https://irongamers.ru/sale/keys/22764> irongamers.ru , , , IronGamers , , , , . , , , , https://irongamers.ru/ , , IronGamers.Ru . .

19/08/2020 20:34:23



PIC18. 2 :
 :
: :
<b> </b>
<i></i>
<a href="http://site.ru"> </a>