![]() | ![]() | ![]() |
| | |||||||
| Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc. |
| | LinkBack | Thread Tools | Display Modes |
| | (permalink) |
| I want to perform both Parallel and SPI interfacing in PIC18F2550 microcontroller.I am interfacing a high speed 8bit ADC(either MAX114 or AD7825) to the PortB of the microcontroller and display the value in a Nokia 6100 color(4K) LCD interfaced by using the SPI interface.I will also send the same value to the PC over USB.The USB part is not a problem. The problem is the pin number 22 which is the PortB.1(RB1/AN10/INT1/SCK/SCL) is also the Serial clock needed for the SPI. Now my question is how can I use both of them simultaneously.Is there any work around for this. I'm using the CCS C Compiler for my PIC programming. | |
| |
| | (permalink) |
| Just put the bit on a free I/O pin. Merge the bit with the other 7 bits in software. Or use a SPI ADC | |
| |
| | (permalink) | |
| Quote:
EDITED: typo corrected - eng1 Last edited by eng1; 19th October 2007 at 10:23 PM. | ||
| |
| | (permalink) | |
| Quote:
| ||
| |
| | (permalink) | |
| Quote:
data1=portb & 0b00001111; data2=porta & 0b11110000; data=data1 | data2; Please correct me if I am wrong. | ||
| |
| | (permalink) |
| Code: data1=portb & 0b11110000; data2=porta & 0b00001111; data=data1 | data2; Code: data = (PORTB & 0xF0) | (PORTA & 0x0F); I've just been able to post my reply, what happened? Last edited by eng1; 20th October 2007 at 11:31 PM. | |
| |
| | (permalink) | |
| Quote:
| ||
| |
| | (permalink) |
| However If I use an SPI ADC can I use the following code to get the conversion data from it. Code: int data;
for(i=0;i<=8;++i)
{
output_high(PIN_B6);
output_low(PIN_B6);
shift_left(&data,1,input(PIN_B7));
} | |
| |
| | (permalink) |
| What you just posted there is a software SPI. That can use any pin combo you want, but its disadvantage is your code is stuck doing that work while in a hardware module it does it in the background... so to speak. It looks like unless you find a way to remap the hardware SCK pin you'll have to use either software SPI or software parallel. Take a look at which one you'll be using more (and its speed) and make the other as a software method. Edit: As a side note, unless you need buffering, I would say software parallel is probably faster since its byte frame, not bit banged. | |
| |
| | (permalink) |
| Or use a 18F4550 and you get a complete 8 bit port RD. | |
| |
| | (permalink) | |
| Quote:
| ||
| |
| | (permalink) |
| I use the CCS compiler myself, and one thing that you should consider is just letting the compiler handle software SPI. When you give the #use SPI command, specify whatever spare pins you have like this: #use spi (DI=PIN_B1, DO=PIN_B0, CLK=PIN_B2, ENABLE=PIN_B4, BITS=16) This will allow you to use spi on pins you have left over on any port, and the coding after this line will be identical. The only issue with doing it with software like this instead of using the PICs dedicated hardware is that it will be considerably slower, but should still be more than fast enough for a small LCD. For more info on this preprocessor directive see pages 124-125 of the CCS compiler manual. One quick addition, with the compilers software SPI you also wont be able to use some (any?) of the SPI interrupts, all sends/receives from the software SPI will be blocking (ie no polling for received data, if you want to receive, you have to know when the data will be coming). Last edited by Stellarcore; 23rd October 2007 at 07:48 PM. | |
| |
| | (permalink) |
| Thank you guys for you help.But finally i decided to use PIC18F4550 | |
| |