Error Using Peripherial i2c Pins Select 16(L)F18346

General discussion on mikroC PRO for PIC.
Post Reply
Author
Message
leo73
Posts: 252
Joined: 09 Jan 2014 15:45

Error Using Peripherial i2c Pins Select 16(L)F18346

#1 Post by leo73 » 19 Oct 2022 15:37

Hello to Every One,
I must use I2C Remappable for my pic model, so i tryed to used it combined to Peripherial Pin Select library; Unfortunatelly compiler show me an error:
<undeclared undefinited _SCK_SCL>
Is strange because i set it like mockoC guide !!!!
Thank you for help me.
Below code:

Code: Select all

#include <SSD1306OLED.c>  //SSD1306 OLED DISPLAY (RES 128X64 PX) OR 128X32, 96X16

// GLOBAL VARIABLES:

// Lcd pinout settings
sbit power_sw at RC6_bit;
sbit mode_sw at RB5_bit;
sbit power_led at RC7_bit;
// Pin direction
sbit power_sw_Direction at TRISC6_bit;
sbit mode_sw_Direction at TRISB5_bit;
sbit power_led_Direction at TRISC7_bit;


//==================== INTERRUPT PROCEDURE =========================
void interrupt()
{
 if (TMR0IF_bit){
  TMR0IF_bit=0;
  TMR0H = 0b1011; // =hex 0b
  TMR0L = 0b11011100; // =dc

  LATC7_bit= ~LATC7_bit;  // led blinking
 }
}

//================== END INTERRUPT PROCEDURE =======================



//===================== LOCAL FUNCTIONS ======================

void arm_interrupt_timer0(){
  T0CON0.T016BIT = 1; // Set timer 0 to work at 16bit
  // bin: 1000; // set prescaler at 1/256
  T0CON1.T0CKIPPS0=0;T0CON1.T0CKIPPS1=0;T0CON1.T0CKIPPS2=0;T0CON1.T0CKIPPS3=1;
  //bin: 011;  // Timer0 Clock Source Select bits-> HFINTOSC
  T0CON1.T0CS0=1;T0CON1.T0CS1=1;T0CON1.T0CS2=0;
  //bin= 0001; // set post scaler at 1/2
  T0CON0.T0OUTPS0=1; T0CON0.T0OUTPS1=0; T0CON0.T0OUTPS2=0;T0CON0.T0OUTPS3=0;
  INTCON	 = 0xC0; // GLOBALiNTERRUPT=ENABLE; ENABLE ALL ACTIVE PERIF.INT.
  TMR0IE_bit	 = 1;  // ENABLE TIMER 0 INTERRUPT
  T0CON0.T0EN = 1; // Start timer
 }

void disarm_interrupt()
{
 T0CON0.T0EN = 1; // stop timer 0
}



//==================== END LOCAL FUNCTIONS ===================


void main() {
// ================== set local Variables ==================
bit power_sw_flag,pass_oly_one_time1,pass_oly_one_time2;//On/off timer0 one time

const char txt[] = "Test";

power_sw_flag=0;
pass_oly_one_time1 = 0; pass_oly_one_time1 = 0;


 //Internal OSCILLATOR_Initialize

// NOSC HFINTOSC; NDIV 4;

OSCCON1 = 0x62; // 0(notUsed), 110(clkSourceReserved), 0010(clkDivider X4)

// CSWHOLD may proceed; SOSCPWR Low power; SOSCBE crystal oscillator;

OSCCON3 = 0x00;

// LFOEN disabled; ADOEN disabled; SOSCEN disabled; EXTOEN disabled; HFOEN disabled;

OSCEN = 0x00;

// HFFRQ 32_MHz;

OSCFRQ = 0x07;

// HFTUN 0;

OSCTUNE = 0x00;

// PORT SET
TRISA=0b00000000;
TRISB=0b00000000;
TRISC=0b00000000;  //0=output, 1=input
PORTA=0; PORTB=0; PORTC=0;

// Disable comparators
  C1ON_bit = 0;
  C2ON_bit = 0;
  CM1CON0=0;
  CM2CON0=0;
  ANSELA = 0x00;  // configure all PORTA pins as digital
  ANSELB = 0x00;  // configure all PORTB pins as digital
  ANSELC = 0b00001111;//select PORTC ch:0,1,2,3 Acquairing Vu-Meter and Spectrum

// Set pins PPS (peripherial pin select library)
Unlock_IOLOCK();

PPS_Mapping_NoLock(_RB6, _OUTPUT, _SCK_SCL);// Sets RB6 for SCL Output
PPS_Mapping_NoLock(_RB4, _OUTPUT, _SDA);   // Sets RB4 for SDA Output

PPS_Mapping_NoLock(_RB6, _INPUT, _SSPCLKPPS); // Set RB6 for SCL Input
PPS_Mapping_NoLock(_RB4, _INPUT, _SSPDATPPS); // Set RB4 for SDA Input

Lock_IOLOCK();

Delay_ms(1000);     // wait a second
I2C1_Remappable_Init(400000);  // initialize I2C communication with clock frequency of 400kHz

SSD1306_Begin(SSD1306_SWITCHCAPVCC, 0x7A); //78  7A

//SSD1306_ClearDisplay();   // clear the buffer


while(1)
 {
 if (Button(&PORTC, 6, 500, 1))  // menaging power on/off
 {
  power_sw_flag = ~power_sw_flag; pass_oly_one_time2=1; pass_oly_one_time1=1;
 }
  if(power_sw_flag == 1)  // power on case
  {
   if(pass_oly_one_time2==1) {disarm_interrupt(); pass_oly_one_time2=0;}

  /*
  sprintf(txt, "%.6f", 3.141592);
  SSD1306_GotoXY(2, 16);
  SSD1306_Print(txt);
  */
  }
 else  // Power off case
  {
   if(pass_oly_one_time1==1) {arm_interrupt_timer0(); pass_oly_one_time1=0;}
  
  }
  
 } // end while(1)
} //end main
Attachments
Error-PPS-Mapping_1.jpg
Error-PPS-Mapping_1.jpg (270.79 KiB) Viewed 938 times
MyProject1.1.zip
(70.23 KiB) Downloaded 29 times
Screenshot_2022-10-19-16-51-12-62_e2d5b3f32b79de1d45acd1fad96fbb0f.jpg
Screenshot_2022-10-19-16-51-12-62_e2d5b3f32b79de1d45acd1fad96fbb0f.jpg (277.82 KiB) Viewed 949 times

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: Error Using Peripherial i2c Pins Select 16(L)F18346

#2 Post by filip » 08 Dec 2022 13:58

Hi,

I apologize for the late reply, have you been able to sort out this issue ?

Regards,
Filip.

paulfjujo
Posts: 1555
Joined: 24 Jun 2007 19:27
Location: 01800 St Maurice de Gourdans France
Contact:

Re: Error Using Peripherial i2c Pins Select 16(L)F18346

#3 Post by paulfjujo » 08 Dec 2022 17:54

hello,



SCL SCK by default ?
maybe you don't need to use PPS for RB6
allready affected to SCL or SCK


be carrefull here
even yet used
sprintf(txt, "%.6f", 3.141592)

:o txt declared as constant ...
you can not modify a constant !

Post Reply

Return to “mikroC PRO for PIC General”