|
|
View previous topic :: View next topic |
Author |
Message |
talamahahahe
Joined: 15 Feb 2015 Posts: 39
|
PIC and NRF24l01 not run |
Posted: Fri Feb 20, 2015 4:35 am |
|
|
I use PIC 16f887 interface with nrf24l01 to transfer and receive data,but it not run. I don't know what problem with it. I was simulate it in Proteus with spi debugger and everything are ok, spi transfer good ...but when i do it, nothing occur. This is my code:
Code: |
#INCLUDE <TV_16F887.C>
#USE SPI(FORCE_HW, BITS=16, stream=SPI_STREAM)
#DEFINE CSN PIN_C0
#DEFINE CE PIN_C1
#DEFINE BUTTON PIN_B0
UNSIGNED INT TX_ADDRESS[TX_ADR_WIDTH]= {0X34,0X43,0X10,0X10,0X01};
UNSIGNED INT RX_ADDRESS[RX_ADR_WIDTH]= {0X34,0X43,0X10,0X10,0X01};
UNSIGNED INT TX_BUF[32]=
{
0x01,0x02,0x03,0x4,0x05,0x06,0x07,0x08,
0x09,0x10,0x11,0x12,0x13,0x14,0x15,0x16,
0x17,0x18,0x19,0x20,0x21,0x22,0x23,0x24,
0x25,0x26,0x27,0x28,0x29,0x30,0x31,0x32,
};
UNSIGNED INT SPI_RW_Reg(UNSIGNED INT REG,VALUE)
{
UNSIGNED INT STATUS1;
OUTPUT_LOW(CSN);
STATUS1=SPI_READ(REG);
SPI_READ(VALUE);
OUTPUT_HIGH(CSN);
RETURN STATUS1;
}
UNSIGNED INT SPI_Write_Buf(unsigned char reg,*pBuf,LIMIT)
{
UNSIGNED INT STATUS1,I;
OUTPUT_LOW(CSN);
STATUS1 = SPI_READ(reg);
FOR(I=0;I<LIMIT;I++) {SPI_READ(*pBuf++);}
OUTPUT_HIGH(CSN);
RETURN(STATUS1);
}
UNSIGNED INT SPI_Read_Buf(unsigned char reg,*pBuf,LIMIT)
{
UNSIGNED INT I,STATUS1;
OUTPUT_LOW(CSN);
STATUS1 = SPI_READ(reg);
FOR(I=0;I<LIMIT;I++) {pBuf[I] = SPI_READ(0);}
OUTPUT_HIGH(CSN);
return(STATUS1);
}
void init_NRF24L01(void)
{
DELAY_US(100);
OUTPUT_LOW(CE);
OUTPUT_HIGH(CSN);
SPI_Write_Buf(WRITE_REG + TX_ADDR, TX_ADDRESS, TX_ADR_WIDTH);
SPI_Write_Buf(WRITE_REG + RX_ADDR_P0, RX_ADDRESS, RX_ADR_WIDTH);
SPI_RW_Reg(WRITE_REG + EN_AA,0X01);
SPI_RW_Reg(WRITE_REG + EN_RXADDR, 0x01);
SPI_RW_Reg(WRITE_REG + RF_CH, 0);
SPI_RW_Reg(WRITE_REG + RX_PW_P0, RX_PLOAD_WIDTH);
SPI_RW_Reg(WRITE_REG + RF_SETUP, 0x07);
SPI_RW_Reg(WRITE_REG + CONFIG, 0x0e);
}
void SetRX_Mode(void)
{
OUTPUT_LOW(CE);
SPI_RW_Reg(WRITE_REG + CONFIG, 0x0f);
OUTPUT_HIGH(CE);
delay_us(130);
}
void SetTX_Mode(void)
{
OUTPUT_LOW(CE);
SPI_RW_Reg(WRITE_REG + CONFIG, 0x0e);
OUTPUT_HIGH(CE);
delay_us(130);
}
UNSIGNED INT nRF24L01_RxPacket(unsigned char *rx_buf)
{
UNSIGNED INT revale=0,STA;
OUTPUT_LOW(CSN);
STA=SPI_Read(STATUS);
OUTPUT_HIGH(CSN);
IF((sta&0x40)!=0)
{
OUTPUT_LOW(CE);
SPI_Read_Buf(RD_RX_PLOAD,rx_buf,TX_PLOAD_WIDTH);
revale =1;
}
SPI_RW_Reg(WRITE_REG+STATUS,STA);
return revale;
}
void nRF24L01_TxPacket(unsigned char * tx_buf)
{
OUTPUT_LOW(CE);
SPI_Write_Buf(WRITE_REG + RX_ADDR_P0, TX_ADDRESS, TX_ADR_WIDTH);
SPI_Write_Buf(WR_TX_PLOAD, tx_buf, TX_PLOAD_WIDTH);
SPI_RW_Reg(WRITE_REG + CONFIG, 0x0e);
OUTPUT_HIGH(CE);
}
VOID MAIN()
{
UNSIGNED INT DATA1,DATA2,DATA3,RXBUF[32];
SET_TRIS_C(0B010000);
SET_TRIS_D(0);
SET_TRIS_E(0);
KHOITAO_LCD();
SETUP_SPI(SPI_MASTER|SPI_L_TO_H|SPI_CLK_DIV_16);
init_NRF24L01();
SetRX_Mode();
WHILE(TRUE)
{
IF(nRF24L01_RxPacket(RxBuf)==1)
{
DATA1=RXBUF[0];
DATA2=RXBUF[1];
DATA3=RXBUF[2];
SetRX_Mode();
}
IF(!INPUT(BUTTON))
{
DELAY_MS(30);
IF(!INPUT(BUTTON))
{
SetTX_Mode();
delay_ms(10);
TX_BUF[0]='A';
TX_BUF[1]='B';
TX_BUF[2]='C';
nRF24L01_TxPacket(Tx_Buf);
SPI_RW_Reg(WRITE_REG+STATUS,0XFF);
SetRX_Mode();
}
}
THIETLAP_LCD(0X80,0);
THIETLAP_LCD(DATA1,1);
THIETLAP_LCD(DATA2,1);
THIETLAP_LCD(DATA3,1);
}
}
|
[img]
SPI TEST
[/img] |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19518
|
|
Posted: Fri Feb 20, 2015 5:26 am |
|
|
Start at the beginning.
There are _two_ completely separate methods of using/configuring SPI with CCS.
#1 (The older method) Setup_spi, with spi_read, and spi_write.
#2 (the recommended method now), #USR_SPI, and spi_xfer.
You can only use one _or_ the other not both. You currently have half of the second, together with the first.
spi_xfer, supports non byte based transfers (16bits etc.).
Then there are loads of problems with your declarations. For instance:
UNSIGNED INT SPI_Write_Buf(unsigned char reg,*pBuf,LIMIT)
What is the type of 'LIMIT'?. int will be assumed, is this what you want?. It is always safer to type everything. Assumptions will differ on different chips and compilers.
Then as a comment, stick to the C standard about capitals. Normally in C, 'ALL CAPITALS' is reserved for things like #defined values.
Then there are lots of things that could be wrong, but we can't tell, since you don't give us the actual declarations for many of the values used. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9229 Location: Greensville,Ontario
|
|
Posted: Fri Feb 20, 2015 6:22 am |
|
|
What's in this file...
#INCLUDE <TV_16F887.C>
??
As we need to see the 'fuses'.
Jay |
|
|
talamahahahe
Joined: 15 Feb 2015 Posts: 39
|
|
Posted: Fri Feb 20, 2015 8:13 am |
|
|
Dear Ttelmah
limit which i declare is a variable. I use it to limit my array transfer like a reg:
Code: | UNSIGNED INT SPI_Write_Buf(unsigned char reg,unsigned int *pBuf, unsigned int limit)
|
I think it same same with
Code: | UNSIGNED INT SPI_Write_Buf(unsigned char reg,*pBuf,LIMIT) |
...but i don't understand about 2 method use spi. I just use ccs help and see all of function in that, so i read it and use it. Can you explain more clearly.
Dear temtronic
#INCLUDE <TV_16F887.C> is my library, actually i don't like use so many function in CCS, it make me don't understand about hardware structure of pic although my university teach CCS instead XC of MBLAB.
So i create a library which declare all of register of pic and use it like: #byte porta = 0x05 (address porta in datasheet)
if you want to see my library, ok i will show you all
Code: |
//////////////////////////////////KHAI BAO THU VIEN/////////////////////////////
#INCLUDE <16F887.H>
//////////////////////////////////KHAI BAO THIET BI ADC 10 BIT//////////////////
#DEVICE ADC=10
//////////////////////////////////KHAI BAO CAU HINH/////////////////////////////
#FUSES HS,NOLVP,PUT,NOPROTECT,NOWDT
//////////////////////////////////KHAI BAO SU DUNG HAM TRE//////////////////////
//#USE DELAY(CLOCK=4M)
#USE DELAY(CLOCK=16M)
//////////////////////////////////KHAI BAO SU DUNG CHUC NANG I2C////////////////
//#USE I2C(MASTER,SLOW,SDA=PIN_C4,SCL=PIN_C3)
//////////////////////////////////KHAI BAO SU DUNG CHUC NANG UART///////////////
//#USE RS232(BAUD=9600,PARITY=N,XMIT=PIN_C6,RCV=PIN_C7,BITS=8,STREAM=PORT1)
//////////////////////////////////KHAI BAO THANH GHI DINH HUONG PORT////////////
#BYTE TRISA = 0X85
#BYTE TRISB = 0X86
#BYTE TRISC = 0X87
#BYTE TRISD = 0X88
#BYTE TRISE = 0X89
//////////////////////////////////KHAI BAO THANH GHI PORT///////////////////////
#BYTE PORTA = 0X05
#BYTE PORTB = 0X06
#BYTE PORTC = 0X07
#BYTE PORTD = 0X08
#BYTE PORTE = 0X09
//////////////////////////////////KHAI BAO THANH GHI TIMER 0////////////////////
#BYTE OPTION_REG = 0X81
#BYTE TMR0 = 0X01
#BIT RBPU = OPTION_REG.7
#BIT INTEDG = OPTION_REG.6
#BIT T0CS = OPTION_REG.5
#BIT T0SE = OPTION_REG.4
#BIT PSA = OPTION_REG.3
#BIT PS2 = OPTION_REG.2
#BIT PS1 = OPTION_REG.1
#BIT PS0 = OPTION_REG.0
/////////////////////////////////KHAI BAO THANH GHI TIMER 1/////////////////////
#BYTE T1CON = 0X10
#BYTE TMR1H = 0X0F
#BYTE TMR1L = 0X0E
#BIT T1GINV = T1CON.7
#BIT TMR1GE = T1CON.6
#BIT T1CKPS1 = T1CON.5
#BIT T1CKPS0 = T1CON.4
#BIT T1OSCEN = T1CON.3
#BIT T1SYNC = T1CON.2
#BIT TMR1CS = T1CON.1
#BIT TMR1ON = T1CON.0
/////////////////////////////////KHAI BAO THANH GHI TIMER 2/////////////////////
#BYTE T2CON = 0X12
#BYTE PR2 = 0X92
#BYTE TMR2 = 0X11
#BIT TOUTPS3 = T2CON.6
#BIT TOUTPS2 = T2CON.5
#BIT TOUTPS1 = T2CON.4
#BIT TOUTPS0 = T2CON.3
#BIT TMR2ON = T2CON.2
#BIT T2CKPS1 = T2CON.1
#BIT T2CKPS0 = T2CON.0
/////////////////////////////////KHAI BAO THANH GHI ADC/////////////////////////
#BYTE ADCON0 = 0X1F
#BYTE ADCON1 = 0X9F
#BYTE ADRESH = 0X1E
#byte ADRESL = 0X9E
#BIT ADON = ADCON0.0
#BIT GODONE = ADCON0.1
#BIT ADFM = ADCON1.7
#BIT CHS0 = ADCON0.2
#BIT CHS1 = ADCON0.3
#BIT CHS2 = ADCON0.4
#BIT CHS3 = ADCON0.5
#BIT ADCS0 = ADCON0.6
#BIT ADCS1 = ADCON0.7
#BIT VCFG0 = ADCON1.4
#BIT VCFG1 = ADCON1.5
/////////////////////////////////KHAI BAO THANH GHI EEPROM//////////////////////
#BYTE EECON1 = 0X18C
#BIT RD = EECON1.0
#BIT WR = EECON1.1
#BIT WREN = EECON1.2
#BIT WRERR = EECON1.3
#BIT EEPGD = EECON1.7
#BYTE EEDAT = 0X10C
#BYTE EEDATH = 0X10E
#BYTE EEADR = 0X10D
#BYTE EEADRH = 0X10F
#BYTE EECON2 = 0X18D
/////////////////////////////////KHAI BAO THANH GHI CCP/////////////////////////
#BYTE CCP1CON = 0X17
#BYTE CCP2CON = 0X1D
#BYTE CCPR1L = 0X15
#BYTE CCPR1H = 0X16
#BYTE CCPR2L = 0X1B
#BYTE CCPR2H = 0X1C
#BIT P1M1 = CCP1CON.7
#BIT P1M0 = CCP1CON.6
#BIT DC1B1 = CCP1CON.5
#BIT DC1B0 = CCP1CON.4
#BIT CCP1M3 = CCP1CON.3
#BIT CCP1M2 = CCP1CON.2
#BIT CCP1M1 = CCP1CON.1
#BIT CCP1M0 = CCP1CON.0
#BIT DC2B1 = CCP2CON.5
#BIT DC2B0 = CCP2CON.4
#BIT CCP2M3 = CCP2CON.3
#BIT CCP2M2 = CCP2CON.2
#BIT CCP2M1 = CCP2CON.1
#BIT CCP2M0 = CCP2CON.0
/////////////////////////////////KHAI BAO THANH GHI EUART///////////////////////
#BYTE TXSTA = 0X98
#BYTE RCSTA = 0X18
#BYTE BAUDCTL = 0X187
#BYTE SPBRG = 0X99
#BYTE SPBRGH = 0X9A
#BYTE TXREG = 0X19
#BYTE RCREG = 0X1A
#BIT SYNC = TXSTA.4
#BIT BRGH = TXSTA.2
#BIT BRG16 = BAUDCTL.3
#BIT SPEN = RCSTA.7
#BIT TXEN = TXSTA.5
#BIT CREN = RCSTA.4
#BIT TRMT = TXSTA.1
/////////////////////////////////KHAI BAO THANH GHI MSSP////////////////////////
#BYTE SSPSTAT = 0X94
#BYTE SSPCON = 0X14
#BYTE SSPCON2 = 0X91
#BYTE SSPBUF = 0X13
#BYTE SSPADD = 0X93
#BIT BF = SSPSTAT.0
#BIT UA = SSPSTAT.1
#BIT RW = SSPSTAT.2
#BIT S = SSPSTAT.3
#BIT P = SSPSTAT.4
#BIT DA = SSPSTAT.5
#BIT CKE = SSPSTAT.6
#BIT SMP = SSPSTAT.7
#BIT SSPM0 = SSPCON.0
#BIT SSPM1 = SSPCON.1
#BIT SSPM2 = SSPCON.2
#BIT SSPM3 = SSPCON.3
#BIT CKP = SSPCON.4
#BIT SSPEN = SSPCON.5
#BIT SSPOV = SSPCON.6
#BIT WCOL = SSPCON.7
#BIT SEN = SSPCON2.0
#BIT RSEN = SSPCON2.1
#BIT PEN = SSPCON2.2
#BIT RCEN = SSPCON2.3
#BIT ACKEN = SSPCON2.4
#BIT ACKDT = SSPCON2.5
#BIT ACKSTAT = SSPCON2.6
#BIT GCEN = SSPCON2.7
/////////////////////////////////KHAI BAO THANH GHI NGAT////////////////////////
#BYTE INTCON = 0X0B
#BYTE PIE1 = 0X8C
#BYTE PIR1 = 0X0C
#BYTE PIE2 = 0X8D
#BYTE PIR2 = 0X0D
#BIT GIE = INTCON.7
#BIT PEIE = INTCON.6
#BIT INTE = INTCON.4
#BIT INTF = INTCON.1
#BIT RBIE = INTCON.3
#BIT RBIF = INTCON.0
#BIT T0IE = INTCON.5
#BIT T0IF = INTCON.2
#BIT T1IE = PIE1.0
#BIT T1IF = PIR1.0
#BIT T2IE = PIE1.1
#BIT T2IF = PIR1.1
#BIT ADIF = PIR1.6
#BIT ADIE = PIE1.6
#BIT CCP1IE = PIE1.2
#BIT CCP1IF = PIR1.2
#BIT CCP2IE = PIE2.0
#BIT CCP2IF = PIR2.0
#BIT TXIE = PIE1.4
#BIT TXIF = PIR1.4
#BIT RCIE = PIE1.5
#BIT RCIF = PIR1.5
#BIT SSPIF = PIR1.3
#BIT SSPIE = PIE1.3
/////////////////////////////////KHAI BAO CHAN CHO LCD//////////////////////////
#BYTE LCD_DATA = PORTD
#BIT LCD_RS = PORTE.0
#BIT LCD_RW = PORTE.1
#BIT LCD_E = PORTE.2
#BIT CS1 = PORTC.0
#BIT CS2 = PORTC.1
#BIT RST = PORTC.2
/////////////////////////////////KHAI BAO MA 7 DOAN/////////////////////////////
INT MA7DOAN[10]={0XC0,0XF9,0XA4,0XB0,0X99,0X92,0X82,0XF8,0X80,0X90};
INT MA7DOAN_DP[10]={0X40,0X79,0X24,0X30,0X19,0X12,0X02,0X78,0X00,0X10};
/////////////////////////////////THIET LAP LCD GIAO THUC 8 BIT TRUYEN///////////
/*
VOID THIETLAP_LCD(INT DATA,INT CHEDO)
{
LCD_RS=CHEDO;
PORTD=DATA;
LCD_E=1;
DELAY_MS(30);
E=0;
}
VOID KHOITAO_LCD()
{
THIETLAP_LCD(0B1,0);
THIETLAP_LCD(0B110,0);
THIETLAP_LCD(0B1100,0);
THIETLAP_LCD(0B111000,0);
}
*/
/////////////////////////////////THIET LAP LCD GIAO THUC 4 BIT TRUYEN///////////
VOID THIETLAP_LCD(INT DATA,INT CHEDO)
{
LCD_RS=CHEDO;
LCD_E=1;
PORTD=((PORTD&0X0F)|(DATA&0XF0));
LCD_E=0;
LCD_E=1;
PORTD=((PORTD&0X0F)|((DATA<<4)&0XF0));
LCD_E=0;
DELAY_MS(1);
}
VOID KHOITAO_LCD()
{
THIETLAP_LCD(0B1,0);
THIETLAP_LCD(0B10,0);
THIETLAP_LCD(0B110,0);
THIETLAP_LCD(0B1100,0);
THIETLAP_LCD(0B101000,0);
}
VOID LCD_PUTS(UNSIGNED INT *S)
{
WHILE(*S)
{
THIETLAP_LCD(*S,1);
S++;
}
}
/////////////////////////////////THIET LAP GLCD GIAO THUC 8 BIT TRUYEN//////////
VOID THIETLAP_GLCD(UNSIGNED INT DULIEU,INT CHEDO)
{
LCD_RS=CHEDO;LCD_RW=0;
PORTD=DULIEU;
LCD_E=1;
DELAY_US(10);
LCD_E=0;
}
VOID KHOITAO_GLCD()
{
CS1=1;CS2=1;RST=1;
THIETLAP_GLCD(0B111111,0);
}
VOID GOTOXY_GLCD(UNSIGNED INT X,UNSIGNED INT Y)
{
IF(X<64) {CS1=0;CS2=1;THIETLAP_GLCD(X+64,0);}
ELSE {CS1=1;CS2=0;THIETLAP_GLCD(X,0);}
THIETLAP_GLCD(Y+184,0);
}
/////////////////////////////////CHUONG TRINH CHO I2C VOI DS1307////////////////
/*
UNSIGNED INT16 CONTROL_DS13,MA_DS13,GIAY_DS13,PHUT_DS13,GIO_DS13,THU_DS13,NGAY_DS13,THANG_DS13,NAM_DS13;
VOID NAP_THOI_GIAN_HTAI_VAO_DS13B07()
{
I2C_START();
I2C_WRITE(0XD0); I2C_WRITE(0X00);
I2C_WRITE(GIAY_DS13);
I2C_WRITE(PHUT_DS13);
I2C_WRITE(GIO_DS13);
I2C_WRITE(THU_DS13);
I2C_WRITE(NGAY_DS13);
I2C_WRITE(THANG_DS13);
I2C_WRITE(NAM_DS13);
I2C_WRITE(CONTROL_DS13); I2C_WRITE(MA_DS13);
I2C_STOP();
}
VOID DOC_THOI_GIAN_TU_REALTIME()
{
I2C_START();
I2C_WRITE(0XD0); I2C_WRITE(0X00);
I2C_START();
I2C_WRITE(0XD1);
GIAY_DS13 = I2C_READ();
PHUT_DS13 = I2C_READ();
GIO_DS13 = I2C_READ();
THU_DS13 = I2C_READ();
NGAY_DS13 = I2C_READ();
THANG_DS13 = I2C_READ();
NAM_DS13 = I2C_READ();
CONTROL_DS13 = I2C_READ();
MA_DS13 = I2C_READ(0);
I2C_STOP();
}
*/
//*********************************************NRF24L01*************************************
#define TX_ADR_WIDTH 5 // 5 uints TX address width
#define RX_ADR_WIDTH 5 // 5 uints RX address width
#define TX_PLOAD_WIDTH 32 // 32 uints TX payload
#define RX_PLOAD_WIDTH 32 // 32 uints TX payload
//***************************************NRF24L01*******************************************************
#define READ_REG 0x00 //
#define WRITE_REG 0x20 //
#define RD_RX_PLOAD 0x61 //
#define WR_TX_PLOAD 0xA0 //
#define FLUSH_TX 0xE1 //
#define FLUSH_RX 0xE2 //
#define REUSE_TX_PL 0xE3 //
#define NOP 0xFF //
//*************************************SPI(nRF24L01)·****************************************************
#define CONFIG 0x00 //
#define EN_AA 0x01 //
#define EN_RXADDR 0x02 //
#define SETUP_AW 0x03 //
#define SETUP_RETR 0x04 //
#define RF_CH 0x05 //
#define RF_SETUP 0x06 //
#define STATUS 0x07 //
#define OBSERVE_TX 0x08 // ·
#define CD 0x09 //
#define RX_ADDR_P0 0x0A //
#define RX_ADDR_P1 0x0B //
#define RX_ADDR_P2 0x0C //
#define RX_ADDR_P3 0x0D //
#define RX_ADDR_P4 0x0E //
#define RX_ADDR_P5 0x0F //
#define TX_ADDR 0x10 //
#define RX_PW_P0 0x11 //
#define RX_PW_P1 0x12 //
#define RX_PW_P2 0x13 //
#define RX_PW_P3 0x14 //
#define RX_PW_P4 0x15 //
#define RX_PW_P5 0x16 //
#define FIFO_STATUS 0x17 //
//************************************************************ |
I think it very bad, but i just a newbie and learn by self about pic....please help me. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9229 Location: Greensville,Ontario
|
|
Posted: Fri Feb 20, 2015 9:02 am |
|
|
here is one big problem..
from your 'header file'.
#USE DELAY(CLOCK=16M)
The PIC can only run at 10MHz or LESS, when Vdd is 3v6 !
You cannot run faster! You've chosen 16M ( 16 MHz ) which exceeeds the design specification. While the PIC you're using now, _might_ run BUT it's NOT a good idea, as the next PIC you try probably won't run.
In the datasheet, in the electrical specs, there's a chart/ figure/chart that shows the allowable 'clock frequency vs. supply voltage'. It is a spec often overlooked as the first page usually says 2V - 5V BUT there are conditions that must be followed.
I had an idea this was the case, as we've all done it !!
Jay |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19518
|
|
Posted: Fri Feb 20, 2015 9:25 am |
|
|
You are also missing the point about types.
You can have a variable called 'LIMIT' with a particular type, but when you declare it in a function header, the variable there is a _new_ declaration.
So the declaration:
"UNSIGNED INT SPI_Write_Buf(unsigned char reg,*pBuf,LIMIT)"
Does _not_ automatically declare 'LIMIT' to be the same type as your variable with the same name.
'LIMIT' in the function, is a _new_ variable. It's type is the type in the function declaration. Using unsigned types in the declaration, means you are relying on what the compiler assumes. It is _meant_ to assume that the variable is the default integer type, but relying on this is dangerous. |
|
|
talamahahahe
Joined: 15 Feb 2015 Posts: 39
|
|
Posted: Fri Feb 20, 2015 12:34 pm |
|
|
Dear Ttelmah
i understand now, your mind is, if we don't declare variable in function, ccs will assume variable is a int. I don't know did i think right??? but i thank for you advice, in this case i want variable "limit" is a unsigned int and maybe i think ccs assumes proper. Its because my teacher say in CCS: int = int8 = char = types 8 bit, so think that, :D but your advice is very helpful, i will remember and attention to it,..but now my project still not run maybe i must test partial of code with proteus....
Dear temtronic
Before and up to now, i always use crystal 16Mhz. I don't know what value of crystal i can use but when i search in website i see almost everyone use crystal up to 20Mhz and in my tutorial which i was taught in university, they still use 20Mhz. So i think i use 16MHZ probably suitable and even i can use prescaler in pic easier. I just do divide 16MHZ for prescaler 16, and i have result 1 pulse=1 us, easier to calculate :D ...this is my opinion, maybe right maybe wrong, however i still appreciate your opinion... |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9229 Location: Greensville,Ontario
|
|
Posted: Fri Feb 20, 2015 12:48 pm |
|
|
There is a potential hardware problem though.
The PIC can be powered by 5 volts and will indeed run at 16MHz however the nrf24 devices are usually powered by 3v6. You cannot run a 5 volt PIC with a 3v6 peripheral device.
Hopefully you're running both PIC and nrf24 from a common 3v6 supply, otherwise, poof !!
Jay |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|