Hello,
I'm working on a project that uses RTC PCF8583 and a 2x16 LCD and I'm testing it in EasyPic5 development board. Both of them will need PortB to be able to work because the LCD is automatically connected to portB and RTC PCF8583 SCL and SDA are at RB0 and RB1.
Does anyone know how to fix this problem?
Any help will be greatly appreciated. Thanks.
Usage of PORTB in EasyPic5 Development Board by RTC and LCD
-
- Posts: 11
- Joined: 05 Jun 2011 01:49
- slavisa.zlatanovic
- mikroElektronika team
- Posts: 1321
- Joined: 07 Apr 2009 09:39
Re: Usage of PORTB in EasyPic5 Development Board by RTC and
Hi!
You could use our Software I²C Library.
Please, consult the compiler's Help file and find out more about it.
You could use our Software I²C Library.
Please, consult the compiler's Help file and find out more about it.
Best regards
Slavisa
Slavisa
-
- Posts: 11
- Joined: 05 Jun 2011 01:49
Re: Usage of PORTB in EasyPic5 Development Board by RTC and
Hi,
I'm using the Soft I2C library as we speak. Upon using PIC16F877A in my code, the RTC functioned the way it was told to do so. However, upon using PIC18F4550, which is the PIC I need for my project, it only displays the text characters, all the important values are not appearing in the 2x16 LCD.
How different is the configuration for PIC18 aside from the SPPCON and INTCON config?
Thanks!
I'm using the Soft I2C library as we speak. Upon using PIC16F877A in my code, the RTC functioned the way it was told to do so. However, upon using PIC18F4550, which is the PIC I need for my project, it only displays the text characters, all the important values are not appearing in the 2x16 LCD.
How different is the configuration for PIC18 aside from the SPPCON and INTCON config?
Thanks!
-
- Posts: 11
- Joined: 05 Jun 2011 01:49
Re: Usage of PORTB in EasyPic5 Development Board by RTC and
Hi,
I'm already using the Soft I2C library as we speak. When I used PIC16F877A with my codes, the RTC and LCD worked well. Upon using PIC18F4550, which is the one I'm supposed to use in my project, the LCD only displays the texts "Date" and "Time" but the time and date do not appear in the LCD.
Are there any configurations that need to be done for PIC18 aside from the SPPCON and INTCON?
Here's our code:
I'm already using the Soft I2C library as we speak. When I used PIC16F877A with my codes, the RTC and LCD worked well. Upon using PIC18F4550, which is the one I'm supposed to use in my project, the LCD only displays the texts "Date" and "Time" but the time and date do not appear in the LCD.
Are there any configurations that need to be done for PIC18 aside from the SPPCON and INTCON?
Here's our code:
Code: Select all
char seconds, minutes, hours, day, month, year; // Global date/time variables
// Software I2C connections
sbit Soft_I2C_Scl at RC3_bit;
sbit Soft_I2C_Sda at RC4_bit;
sbit Soft_I2C_Scl_Direction at TRISC3_bit;
sbit Soft_I2C_Sda_Direction at TRISC4_bit;
// End Software I2C connections
// LCD module connections
sbit LCD_RS at RB4_bit;
sbit LCD_EN at RB5_bit;
sbit LCD_D4 at RB0_bit;
sbit LCD_D5 at RB1_bit;
sbit LCD_D6 at RB2_bit;
sbit LCD_D7 at RB3_bit;
sbit LCD_RS_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB5_bit;
sbit LCD_D4_Direction at TRISB0_bit;
sbit LCD_D5_Direction at TRISB1_bit;
sbit LCD_D6_Direction at TRISB2_bit;
sbit LCD_D7_Direction at TRISB3_bit;
// End LCD module connections
//--------------------- Reads time and date information from RTC (PCF8583)
void Read_Time() {
Soft_I2C_Start(); // Issue start signal
Soft_I2C_Write(0xA0); // Address PCF8583, see PCF8583 datasheet
Soft_I2C_Write(2); // Start from address 2
Soft_I2C_Start(); // Issue repeated start signal
Soft_I2C_Write(0xA1); // Address PCF8583 for reading R/W=1
seconds = Soft_I2C_Read(1); // Read seconds byte
minutes = Soft_I2C_Read(1); // Read minutes byte
hours = Soft_I2C_Read(1); // Read hours byte
day = Soft_I2C_Read(1); // Read year/day byte
month = Soft_I2C_Read(0); // Read weekday/month byte
Soft_I2C_Stop(); // Issue stop signal
}
//-------------------- Formats date and time
void Transform_Time() {
seconds = ((seconds & 0xF0) >> 4)*10 + (seconds & 0x0F); // Transform seconds
minutes = ((minutes & 0xF0) >> 4)*10 + (minutes & 0x0F); // Transform months
hours = ((hours & 0xF0) >> 4)*10 + (hours & 0x0F); // Transform hours
year = (day & 0xC0) >> 6; // Transform year
day = ((day & 0x30) >> 4)*10 + (day & 0x0F); // Transform day
month = ((month & 0x10) >> 4)*10 + (month & 0x0F); // Transform month
}
//-------------------- Output values to LCD
void Display_Time() {
Lcd_Chr(1, 6, (day / 10) + 48); // Print tens digit of day variable
Lcd_Chr(1, 7, (day % 10) + 48); // Print oness digit of day variable
Lcd_Chr(1, 9, (month / 10) + 48);
Lcd_Chr(1,10, (month % 10) + 48);
Lcd_Chr(1,15, year + 48); // Print year variable (start from year 2010)
Lcd_Chr(2, 6, (hours / 10) + 48);
Lcd_Chr(2, 7, (hours % 10) + 48);
Lcd_Chr(2, 9, (minutes / 10) + 48);
Lcd_Chr(2,10, (minutes % 10) + 48);
Lcd_Chr(2,12, (seconds / 10) + 48);
Lcd_Chr(2,13, (seconds % 10) + 48);
}
//------------------ Performs project-wide init
void Init_Main() {
TRISB = 0;
PORTB = 0xFF;
TRISB = 0xff;
SPPCON = 0x02;
INTCON = 0x00;
ADCON1 = 0x0F;
Soft_I2C_Init(); // Initialize Soft I2C communication
Lcd_Init(); // Initialize LCD
Lcd_Cmd(_LCD_CLEAR); // Clear LCD display
Lcd_Cmd(_LCD_CURSOR_OFF); // Turn cursor off
Lcd_Out(1,1,"Date:"); // Prepare and output static text on LCD
Lcd_Chr(1,8,'.');
Lcd_Chr(1,11,'.');
Lcd_Chr(1,16,'.');
Lcd_Out(2,1,"Time:");
Lcd_Chr(2,8,':');
Lcd_Chr(2,11,':');
Lcd_Out(1,12,"201"); // start from year 2010
}
//----------------- Main procedure
void main() {
Delay_ms(500);
Init_Main(); // Perform initialization
while (1) { // Endless loop
Read_Time(); // Read time from RTC(PCF8583)
Transform_Time(); // Format date and time
Display_Time(); // Prepare and display on LCD
}
}
-
- Posts: 11
- Joined: 05 Jun 2011 01:49
Re: Usage of PORTB in EasyPic5 Development Board by RTC and
Hi,
I'm already using the Soft I2C library as we speak. When I used PIC16F877A with my codes, the RTC and LCD worked well. Upon using PIC18F4550, which is the one I'm supposed to use in my project, the LCD only displays the texts "Date" and "Time" but the time and date do not appear in the LCD.
Are there any configurations that need to be done for PIC18 aside from the SPPCON and INTCON?
Here's our code:
I'm already using the Soft I2C library as we speak. When I used PIC16F877A with my codes, the RTC and LCD worked well. Upon using PIC18F4550, which is the one I'm supposed to use in my project, the LCD only displays the texts "Date" and "Time" but the time and date do not appear in the LCD.
Are there any configurations that need to be done for PIC18 aside from the SPPCON and INTCON?
Here's our code:
Code: Select all
char seconds, minutes, hours, day, month, year; // Global date/time variables
// Software I2C connections
sbit Soft_I2C_Scl at RC3_bit;
sbit Soft_I2C_Sda at RC4_bit;
sbit Soft_I2C_Scl_Direction at TRISC3_bit;
sbit Soft_I2C_Sda_Direction at TRISC4_bit;
// End Software I2C connections
// LCD module connections
sbit LCD_RS at RB4_bit;
sbit LCD_EN at RB5_bit;
sbit LCD_D4 at RB0_bit;
sbit LCD_D5 at RB1_bit;
sbit LCD_D6 at RB2_bit;
sbit LCD_D7 at RB3_bit;
sbit LCD_RS_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB5_bit;
sbit LCD_D4_Direction at TRISB0_bit;
sbit LCD_D5_Direction at TRISB1_bit;
sbit LCD_D6_Direction at TRISB2_bit;
sbit LCD_D7_Direction at TRISB3_bit;
// End LCD module connections
//--------------------- Reads time and date information from RTC (PCF8583)
void Read_Time() {
Soft_I2C_Start(); // Issue start signal
Soft_I2C_Write(0xA0); // Address PCF8583, see PCF8583 datasheet
Soft_I2C_Write(2); // Start from address 2
Soft_I2C_Start(); // Issue repeated start signal
Soft_I2C_Write(0xA1); // Address PCF8583 for reading R/W=1
seconds = Soft_I2C_Read(1); // Read seconds byte
minutes = Soft_I2C_Read(1); // Read minutes byte
hours = Soft_I2C_Read(1); // Read hours byte
day = Soft_I2C_Read(1); // Read year/day byte
month = Soft_I2C_Read(0); // Read weekday/month byte
Soft_I2C_Stop(); // Issue stop signal
}
//-------------------- Formats date and time
void Transform_Time() {
seconds = ((seconds & 0xF0) >> 4)*10 + (seconds & 0x0F); // Transform seconds
minutes = ((minutes & 0xF0) >> 4)*10 + (minutes & 0x0F); // Transform months
hours = ((hours & 0xF0) >> 4)*10 + (hours & 0x0F); // Transform hours
year = (day & 0xC0) >> 6; // Transform year
day = ((day & 0x30) >> 4)*10 + (day & 0x0F); // Transform day
month = ((month & 0x10) >> 4)*10 + (month & 0x0F); // Transform month
}
//-------------------- Output values to LCD
void Display_Time() {
Lcd_Chr(1, 6, (day / 10) + 48); // Print tens digit of day variable
Lcd_Chr(1, 7, (day % 10) + 48); // Print oness digit of day variable
Lcd_Chr(1, 9, (month / 10) + 48);
Lcd_Chr(1,10, (month % 10) + 48);
Lcd_Chr(1,15, year + 48); // Print year variable (start from year 2010)
Lcd_Chr(2, 6, (hours / 10) + 48);
Lcd_Chr(2, 7, (hours % 10) + 48);
Lcd_Chr(2, 9, (minutes / 10) + 48);
Lcd_Chr(2,10, (minutes % 10) + 48);
Lcd_Chr(2,12, (seconds / 10) + 48);
Lcd_Chr(2,13, (seconds % 10) + 48);
}
//------------------ Performs project-wide init
void Init_Main() {
TRISB = 0;
PORTB = 0xFF;
TRISB = 0xff;
SPPCON = 0x02;
INTCON = 0x00;
ADCON1 = 0x0F;
Soft_I2C_Init(); // Initialize Soft I2C communication
Lcd_Init(); // Initialize LCD
Lcd_Cmd(_LCD_CLEAR); // Clear LCD display
Lcd_Cmd(_LCD_CURSOR_OFF); // Turn cursor off
Lcd_Out(1,1,"Date:"); // Prepare and output static text on LCD
Lcd_Chr(1,8,'.');
Lcd_Chr(1,11,'.');
Lcd_Chr(1,16,'.');
Lcd_Out(2,1,"Time:");
Lcd_Chr(2,8,':');
Lcd_Chr(2,11,':');
Lcd_Out(1,12,"201"); // start from year 2010
}
//----------------- Main procedure
void main() {
Delay_ms(500);
Init_Main(); // Perform initialization
while (1) { // Endless loop
Read_Time(); // Read time from RTC(PCF8583)
Transform_Time(); // Format date and time
Display_Time(); // Prepare and display on LCD
}
}
-
- Posts: 11
- Joined: 05 Jun 2011 01:49
Re: Usage of PORTB in EasyPic5 Development Board by RTC and
hi,
just a follow up question. does the EASYPIC5 development board have internal connections beside those that are printed at the top surface of the board itself? because we really can't use the LCD and RTC at the same time since they both need Port B (SCL and SDA needed for I2C of PIC18F4455 is in RB1 and RB0 respectively), we tried to do the connections in breadboard following the corresponding pins printed on the dev board.
to confirm that we are just having problem with our code, we tried first PIC16 on the dev board, and it worked properly. then we tried exactly the same program, this time the PIC16 is on breadboard, but it does not display anything. so, it means that the problem is with the connection. do you have any idea on how we can troubleshoot the missing connections?
thank you very much!
just a follow up question. does the EASYPIC5 development board have internal connections beside those that are printed at the top surface of the board itself? because we really can't use the LCD and RTC at the same time since they both need Port B (SCL and SDA needed for I2C of PIC18F4455 is in RB1 and RB0 respectively), we tried to do the connections in breadboard following the corresponding pins printed on the dev board.
to confirm that we are just having problem with our code, we tried first PIC16 on the dev board, and it worked properly. then we tried exactly the same program, this time the PIC16 is on breadboard, but it does not display anything. so, it means that the problem is with the connection. do you have any idea on how we can troubleshoot the missing connections?
thank you very much!
- slavisa.zlatanovic
- mikroElektronika team
- Posts: 1321
- Joined: 07 Apr 2009 09:39
Re: Usage of PORTB in EasyPic5 Development Board by RTC and
Hi!
If you want, I can email you the EasyPIC5 dev. board schematic?just a follow up question. does the EASYPIC5 development board have internal connections beside those that are printed at the top surface of the board itself?
Best regards
Slavisa
Slavisa
-
- Posts: 11
- Joined: 05 Jun 2011 01:49
Re: Usage of PORTB in EasyPic5 Development Board by RTC and
Hi,
Please find the schematic attached.
Regards,
Filip.
Please find the schematic attached.
Regards,
Filip.
- Attachments
-
- EASY-PIC5_Schematic_v102_BB.rar
- (58.52 KiB) Downloaded 143 times
-
- Posts: 11
- Joined: 05 Jun 2011 01:49
Re: Usage of PORTB in EasyPic5 Development Board by RTC and
Thank you very much for this