milan.rajik
Banned

He will be using the circuit mentioned in post #38.
SPI_IN_OUT
movf DATA_OUT,w ; get datum for transmission
movwf SSPBUF ;put into SSPBUF
SS_IN_OUT_LOOP
btfss SSPCON,WCOL ; dit it make it ?
goto SPI_IN_OUT_CONT ; if so THEN continue
bcf SSPCON,WCOL ;Else reset WCOL and try again
goto SSP_IN_OUT_LOOP
SPI_IN_OUT_CONT
bsf STATUS ,RPO ; Change to Bank0
btfss SSPSTAT ,BF ; check for buffer full
goto SPI_IN_OUT_CONT ; if not then poll again
bcf STATUS ,RPO ; Back to Bank1
movf SSPBUF ,w ; else get the received datum
movwf DATA_IN ; put away
return
SPI (SPI data and clk SPI) SPI standard with a line for the clk and a line for datas (so two I/O)
is that correct? only (SPI data and clk SPI)
Code:SPI_IN_OUT movf DATA_OUT,w ; get datum for transmission movwf SSPBUF ;put into SSPBUF SS_IN_OUT_LOOP btfss SSPCON,WCOL ; dit it make it ? goto SPI_IN_OUT_CONT ; if so THEN continue bcf SSPCON,WCOL ;Else reset WCOL and try again goto SSP_IN_OUT_LOOP SPI_IN_OUT_CONT bsf STATUS ,RPO ; Change to Bank0 btfss SSPSTAT ,BF ; check for buffer full goto SPI_IN_OUT_CONT ; if not then poll again bcf STATUS ,RPO ; Back to Bank1 movf SSPBUF ,w ; else get the received datum movwf DATA_IN ; put away return
Does your PIC have Hardware SPI ? I don't know. If you use the circuit mentioned in post #38 then you are sending data serially. It is not SPI. It is different from SPI. Only if your PIC has hardware SPI there will be SSPBUF and other registers associated with SPI.
So one LCD driven by SPI. that's what I'd like to code
- - - Updated - - -
My Pic has no Hardware SPI I have to code a SPI software only Interface to the LCD module, one LCD driven by SPI
only Interface to the LCD module -->(SPI data and clk SPI)
If you want to use SPI for LCD then you have to mention what SPI port expander you will use between PIC and LCD. Will you use MCP23S09 8 bit port expander between PIC and LCD. If you can use MCP23S09 then I will try to port my C code to asm.
I repeat you CAN NOT use SPI.
SPI requires THREE connections - you only have two.
milan.rajik, please look at the data sheet for this PIC. It is one of the baseline processors, available in 6 or 8 pin (with 2 pins unused!) packages , only 256 bytes of program memory and 16 bytes of RAM. It has no internal peripherals except one 8-bit timer and an 8-bit ADC. Most importantly here, it only has three IO pins and one input pin. One of the IO pins has to be used as the analog input.
Brian.
I do not know if anyone understands me; because I'm already sick with this theme, and the teacher does not respond to the written questions , he said, just to do what was written in the book of specifications
It can be done with a CD4094, 75LS595, 75HC164 or any other shift register but it will not work with SPI. if you put SPI in permanent 'enabled' state it will never latch the serial bits to the parallel output pins. If you use the LED examples in the previous posts, it will not work with LCD and random segments will appear during the bit shifting.
I understand your frustration but you have given us very little information to work from and been indecisive about the type of display you intend to use. You started with a parallel LCD, then wanted SPI LCD and your latest post is showing a (bad) design for LED. I think this is supposed to be an exercise in learning how to overcome a simple task when you have limited resources but you seem to be pushing us to do the work for you instead of trying to understand the options available to you. Edaboard is not a free "do your homework for you" service, all of us are volunteers who give our time freely to help you but we try to teach and guide you so you can solve problems yourself.
Brian.
SCL EQU 0 ;Serial clock
SDA EQU 1 ;Serial data
; WITH SCL HIGH).
; WITH SCL HIGH).
bsf <pin name>
bcf <pin name>
rrf <data>,f
movlw 8 ;counter for the number of bits to send
movwf Counter
SerialLoop
rrf LCD_Data,f ;rotate right putting LSB in C flag
btfss STATUS,C ;skip next instruction if C is 1
goto SendLow
bsf Data ;make the Data pin high
goto SendClock
SendLow
bcf Data ;make the data pin low
SendClock
bcf Clock ;make clock pin low
bsf Clock ;make clock pin high again
decfsz Counter,f ;see if all 8 bits have been sent...
goto SerialLoop ;... keep looping until all sent
Make a pin high with
Make a pin low withCode:bsf <pin name>
Code:bcf <pin name>
To convert a byte to serial format, rotate it with
so the least significant bit (bit 0) is moved into the 'C' (Carry bit) in STATUS where you can test it. You do the same with 'rlf' if you want the MSB first.Code:rrf <data>,f
This is a full software parallel to serial converter routine. I have not tested it.
Code:movlw 8 ;counter for the number of bits to send movwf Counter SerialLoop rrf LCD_Data,f ;rotate right putting LSB in C flag btfss STATUS,C ;skip next instruction if C is 1 goto SendLow bsf Data ;make the Data pin high goto SendClock SendLow bcf [COLOR="#FF0000"]Data[/COLOR] ;make the data pin low SendClock bcf [COLOR="#FF0000"]Clock[/COLOR] ;make clock pin low bsf Clock ;make clock pin high again decfsz Counter,f ;see if all 8 bits have been sent... goto SerialLoop ;... keep looping until all sent
See if you can follow it and debug if necessary.
Brian.
#define CLK GPIO,1
#define DATA GPIO,2
STROBE MACRO
bsf CLK
call Delay500us
bcf CLK
ENDM