Jump to content

Passah

EstablishedMember
  • Content Count

    5
  • Joined

  • Last visited

Community Reputation

0 Neutral

About Passah

  • Rank
    Newbrie
  1. Sorry the first reply is an error Regards Pascal
  2. Hi, I finally have my SPI port working correctly so I give you the code: #include void initSPI(void) { // Port C portc = 0x00; trisc = 0x10; // Port D trisd = 0x00; portd = 0x02; // Port A trisa = 0x00; // Disbale interrupt pie1 = 0x00; intcon = 0x00; // Config SSPCON //Set up SPI port, Master mode, CLK/16, //Data xmit on falling edge (CKE=1 & CKP=1) sspcon = 0x32; } void writeSPI(void) { unsigned char rxdata; // Send data sspbuf = 0xAA; // Test if transmission is done (BF = 1) while ((sspstat & 0x01) == 0); rxdata = sspbuf; // Clear BF //Send CS portd = 0x02; // RD_SWITCH = 1, WR_LEDS = 0 portd = 0x03; // RD_SWITCH = 1, WR_LEDS = 1 } main() { initSPI(); for(; { writeSPI(); } }
  3. Hi, I finally have my SPI port working correctly so I give you the code: #include unsigned char rxdata = 0; void initSPI(void) { // Port C portc = 0x00; trisc = 0x10; // Port D trisd = 0x00; portd = 0x02; // Port A trisa = 0x00; // Disbale interrupt pie1 = 0x00; intcon = 0x00; // Config SSPCON //Set up SPI port, Master mode, CLK/16, //Data xmit on falling edge (CKE=1 & CKP=1) sspcon = 0x32; } void writeSPI(void) { unsigned char rxdata; // Send data sspbuf = 0xAA; while ((sspstat & 0x01) == 0); // Test si tranmission terminee (BF = 1) rxdata = sspbuf; // Clear BF //Send CS portd = 0x02; // RD_SWITCH = 1, WR_LEDS = 0 portd = 0x03; // RD_SWITCH = 1, WR_LEDS = 1 } */ main() { initSPI(); for(; { writeSPI(); } }
  4. Hi I have some problem to make my SPI port work on a PIC16F77. PIC should be in master mode with a hard CS on pin RD0. Here is my code: #include //Define device config block asm { list p=PIC16F77 __config _HS_OSC & _WDT_OFF & _PWRTE_OFF & _CP_OFF & _BODEN_ON; } void initSPI(void) { // Port C trisc = 0x10; // Port D trisd = 0x00; portd = 0x02; // Port A trisa = 0x00; // Config SSPSTAT sspstat = 0x00; // SMP = 0, CKE = 0, and clear status bits (BF) set_bit(sspstat,CKE); // CKE = 1 // Config SSPCON sspcon = 0x31; //Set up SPI port, Master mode, CLK/16, //Data xmit on falling edge (CKE=1 & CKP=1) // Enable SSP interrupt clear_bit(pie1,SSPIE); // enable interrupts disable_interrupt(GIE); } void writeSPI(void) { unsigned char rxdata; while ((sspstat & 0x01) == 1); // Test si tranmission en cours (BF = 1) // Send data rxdata = sspbuf; // Clear BF sspbuf = 0x55; // Send CS portd = 0x02; // RD_SWITCH = 1, WR_LEDS = 0 portd = 0x03; // RD_SWITCH = 1, WR_LEDS = 1 } main() { initSPI(); for(; { writeSPI(); } } Can someone help me plz ? Thx Pascal
  5. Hi, I am trying to use struct but it don't seems to be implemented or I am using them in the wrong way. My code is: struct keypad { unsigned char key; unsigned short count; } ; typedef struct keypad T_keypad; Is that possible to use struct like that ? Regards Pascal
×
×
  • Create New...