|
|
View previous topic :: View next topic |
Author |
Message |
vtrx
Joined: 11 Oct 2017 Posts: 142
|
IC2 and SPI on Port B |
Posted: Mon May 18, 2020 6:18 pm |
|
|
I'm using simulation on Proteus, a circuit that uses SPI and IC2 communication.
I use B2, B3, B4 and B5 to control an LCD, and B0 and B1 for IC2.
In Proteus the simulation works.
I haven't set up the circuit yet, but because it works on Proteus, will it work on a real circuit?
Code: | #use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
#define EEPROM_SDA PIN_B0
#define EEPROM_SCL PIN_B1
#define LCD_DC PIN_B2 // data/command pin
#define LCD_DAT PIN_B3 // data in pin (MOSI)
#define LCD_CLK PIN_B4 // clock pin
#define LCD_CS PIN_B5 // chip select pin, optional!
#use i2c(master, sda=EEPROM_SDA, scl=EEPROM_SCL, FORCE_HW)
#use SPI(DO = LCD_DAT, CLK = LCD_CLK, MODE = 3, BITS = 8, STREAM = LCD_STREAM) //LCD USA SPI POR SOFTWARE |
|
|
|
Gabriel
Joined: 03 Aug 2009 Posts: 1067 Location: Panama
|
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9226 Location: Greensville,Ontario
|
|
Posted: Mon May 18, 2020 7:52 pm |
|
|
I've yet to see a Proteus schematic posted that will actually work in the real World.....1/4 century 'playin with PICs' and still waiting.. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19510
|
|
Posted: Mon May 18, 2020 11:57 pm |
|
|
As others have said, 'beware'.
I use Proteus. Now it's simulation of the PIC processor in general is 95%
'right' at best. It does not know about 'oddities' in individual chips,
and does not correctly handle many of the default things (the way
that pins float for example).
With 'care', it is possible to simulate, and get close to real behaviour.
However it is also possible to leave small things unconfigured in the
simulation, that in the real chip would be disastrous, and 'get away' with
these....
Generally, the more complex the peripheral, the worse the simulation
is. It behaves very badly when handling I2C for example.
I have circuits that Proteus says will not work, yet in a real chip they
run fine. I also have ones that Proteus says can work, but in the
real world fail.
The simulation of the PIC in particular seems worse than many other
chips. I suspect this is because of the sheer number of PIC models,
and the way that no two behave exactly the same.
It also ignores important things like interference, smoothing, and
capacitive loading, though figures for these exist in parts of the
simulation.
Relying on Proteus is in 'chocolate fireguard' territory.
I like Proteus as a PCB package. However the 'Isis' simulator is the
cause of more grief, especially among students, whose teachers seem
determined to encourage it's use, than almost any other package in
existence... |
|
|
vtrx
Joined: 11 Oct 2017 Posts: 142
|
|
Posted: Tue May 19, 2020 4:41 am |
|
|
Gabriel wrote: | https://www.ccsinfo.com/forum/viewtopic.php?t=47549
The answer to all proteus questions! |
Thanks for the answer.
I don't think i asked correctly.
My question is not about Proteus, but if the portb can be used as I / O and at the same time IC2. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9226 Location: Greensville,Ontario
|
|
Posted: Tue May 19, 2020 5:47 am |
|
|
re: Quote: | if the portb can be used as I / O and at the same time IC2 |
short answer Yes,
longer answer,
Which PIC ?
Are you using a hardware I2C peripheral or 'bit bang' I2C ? If the HW I2C, again yes. If SW, maybe, as it depends upon what is actually needed to be done.
Do you mean can the SAME I/O pin be used for BOTH I/O AND I2C ? generally no, but depending on what is attached to the pin...maybe...
'at the same time'. Depending on external devices(what's on the I/O pins) yes but there WILL be a determinable delay between say setting an I/O pin and an I2C operation. That'll be based on PIC clock speed, type of I/O( fast/std) and whatever the program is doing...
We'd need more specific information about the PIC and what it's supposed to do.....to give a better answer. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19510
|
|
Posted: Tue May 19, 2020 6:16 am |
|
|
You only have pin B6 & B7 left.
Provided you use standard IO, and the standard functions to access these,
then 'yes'. However it is possible to write things in ways that won't work. |
|
|
vtrx
Joined: 11 Oct 2017 Posts: 142
|
|
Posted: Tue May 19, 2020 6:29 am |
|
|
This is the initial configuration (18F2550)
Quote: | #define EEPROM_SDA PIN_B0
#define EEPROM_SCL PIN_B1
#define LCD_DC PIN_B2 // data/command pin
#define LCD_DAT PIN_B3 // data in pin (MOSI)
#define LCD_CLK PIN_B4 // clock pin
#define LCD_CS PIN_B5 // chip select pin, optional!
#use i2c(master, sda=EEPROM_SDA, scl=EEPROM_SCL, FORCE_HW)
#use SPI(DO = LCD_DAT, CLK = LCD_CLK, MODE = 3, BITS = 8, STREAM = LCD_STREAM) //LCD USA SPI POR SOFTWARE |
|
|
|
|
|
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
|