Andre, & means "The address of" It gives you the memory location of the variable data. When you make portb all low you are writing 0b00000000 to address F81h(portb on 18f452) If you declare a pointer variable int *a; and a variable int b=3; and you then say a=&b; a will contain the address of b not the value of b. Pete -----Original Message----- From: piclist-bounces@mit.edu [mailto:piclist-bounces@mit.edu]On Behalf Of Andre Abelian Sent: Monday, November 28, 2005 9:23 PM To: Microcontroller discussion list - Public. Subject: Re: [pic]: Problem with PortB Pete, thaks for your input yes that was the problem with shifting. what is the purpose of & ? Andre peteHVAC wrote: >Hello, >Not sure if I can help much but it looks like shift_left should be >output_bit(PS2_DATA_OUT, shift_left(&data,1,0)); >data needs to be a structure or array shift needs the address of data &data >Not sure about the port. Single step the program and watch for changes? > >I'm just starting with CCS too. If you post some more code maybe I can help. >If you need SPI you should use the built in stuff very easy + lots of >examples. > >If your rewriting PICC\Examples\EX_MOUSE.C maybe you should get that working >first. > >http://www.ccsinfo.com/forum/ is a good place to hang out. > >A very good book is PICmicro MCU C by Nigel Gardner ISBN 0-9724181-0-5 >Hope this helps. > >Pete > >-----Original Message----- >From: piclist-bounces@mit.edu [mailto:piclist-bounces@mit.edu]On Behalf >Of Andre Abelian >Sent: Monday, November 28, 2005 7:42 PM >To: Microcontroller discussion list - Public. >Subject: [pic]: Problem with PortB > > >strange > >Hi to all, > >when I set break point on portB bit 4 other pins turn on too and >shift_left doesn't work >I worked on it whole day and I gave up. I appreciate if any one can see >what I >am doing wrong. I am not sure if what I put together is real SPI >interface what >I wanted to do is to make spi interface. here is partial code. >I am using 18f452 with mplab ccs plugin > >thanks > >Andre > > > >#include <18F252.h> >#device ADC=8 >#fuses HS,NOWDT,NOPROTECT,NOLVP >#use delay(clock=4000000) // >#use rs232(baud=1200, xmit=PIN_C6, rcv=PIN_C7,errors) // >#define MICROSOFT TRUE >#define MOUSE_SYSTEMS FALSE >#DEFINE LEFT_BUTTON PIN_B6 >#DEFINE RIGHT_BUTTON PIN_B7 >#DEFINE X_CHANNEL 0 >#DEFINE Y_CHANNEL 1 >#define PS2_CLK_OUT PIN_B4 // >#define PS2_DATA_OUT PIN_B5 // >#define PS2_CLK_IN PIN_B1 // >#define PS2_DATA_IN PIN_B0 // >#define LED PIN_C3 > > > >void ps2_out(BYTE data) >{ > BYTE i; > > output_low(PS2_CLK_OUT); // start bit on > for(i=1;i<=8;++i) > { > output_bit(PS2_DATA_OUT, shift_left(data,1,0)); > output_high(PS2_CLK_OUT); // <= I set break point here > output_low(PS2_CLK_OUT); > } > output_low(PS2_DATA_OUT); > delay_ms(11); >} > >-- >http://www.piclist.com PIC/SX FAQ & list archive >View/change your membership options at >http://mailman.mit.edu/mailman/listinfo/piclist > > > -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist