Hi N,That sounds a very strange thing to do?, the problem is almost certainly something you're doing wrong.
First off, have you disabled slew rate control? (SLRCON registers), the default is ON, and this cripples SPI speed - it 'might' work at 8MHz, it might not, or it might work 'sometimes' - it's something you absolutely need to turn OFF. However, if it's not working at 2MHz, that's unlikely to be the issue - but it still wants turning OFF (it's up there with ANSEL, the defaults are stupid).
Hi I,Hi Nigel, The power supply will need to be concreate for this device to work on a 3V3 supply
I have had issues before running these chinesium LCD's, as have you. On the Fantastic "Geoff's projects" pages, they used the same screen on Pico's and Micromites (Pic32) but they supply 5V for the screen's power.
When I tested this on my breadboard, it works with a pic18f46k22, but not a pic18f46k20. the latter is 3v3 only... I think this is the problem The PSU on the breadboard is a 3V3 switch mode 7803 replacement.
GoodHi N,
SLRCON =0.
C
Hi I,
I use 12V batteries, then 7805, then 3.3v LDO to get the 3.3v.
I've put the Regs that you suggest in the Farnell Basket.
C.
Hi N,Are they cheaper at Farnell than at RS?, often things are - but not always, and sometimes they are more expensive?. It's also worth checking CPC (a division of Farnell) as they are often considerably cheaper.
For example, last week I was re-ordering some LED mounting clips, which we normally source from Farnell, they were £6.50 odd for 25, but out of stock, expected delivery date 10 weeks.
So I checked RS, in stock, but similar price for only FIVE!! - so I googled the manufacturers (Kingbright) part number, and up popped CPC, in stock, and only £4 for 25 - happy days!
On a similar theme, we use a LOT of four core cable, originally from RS, but it was always out of stock, then the P/N changed, more out of stock, and going from the number in stock when it was, we were the only people buying itEventually they discontinued it entirely, and we ended up using a slightly inferior American cable from Farnell.
It's available on 100ft or 1000ft drums (because it's American), and rather bizarrely it was considerably cheaper to buy 10x100ft drums, than one 1000 foot drum (no problem, because we cut it into short lengths) - which made no sense. Anyway, we've been happily buying the little drums. But the other week I had to order more, so (as always) I checked the 1000ft drums - it was now cheaper than ten 100ft drums - so I ordered five drums, as there's a price break at five, they only had three in stock, but you get the price break anyway, and the other two will arrive later (they haven't yet).
It's often an adventure ordering parts!
I have verified that the Oshonsoft compiler leaves it at 1 by default, in my case as I am using the Pic18F46K22 the value is SLRCON = %11111.That sounds a very strange thing to do?, the problem is almost certainly something you're doing wrong.
First off, have you disabled slew rate control? (SLRCON registers), the default is ON, and this cripples SPI speed - it 'might' work at 8MHz, it might not, or it might work 'sometimes' - it's something you absolutely need to turn OFF. However, if it's not working at 2MHz, that's unlikely to be the issue - but it still wants turning OFF (it's up there with ANSEL, the defaults are stupid).
Hi D,I have verified that the Oshonsoft compiler leaves it at 1 by default, in my case as I am using the Pic18F46K22 the value is SLRCON = %11111.
In my case, since all my projects work just fine, I keep it enabled. I still build a few that get installed in places with loads of electronics around. Honestly, I had totally forgotten about this register — I checked once that it was enabled by default and haven’t thought about it since.
'Example: Call _SPI1_Init(_SPI_MODE0, _SPI_MASTER_SPEED1 | _SPI_ENABLE) 'CLK 4Mhz (64Mhz)
Proc _SPI1_Init(mode As Byte, speed As Byte)
' Configure SPI pins
ConfigPin _SPI_SCK = Output ' SCK as output
ConfigPin _SPI_SDI = Input ' SDI as input
ConfigPin _SPI_SDO = Output ' SDO as output
ConfigPin _SPI_RST = Output ' RESET as output
ConfigPin _SPI_DC = Output ' DC (SS) Data/Command pin as output
ConfigPin _SPI_CS = Output ' CS Chip Select pin
' Estado inicial de los pin
_SPI_RST = 1 ' RST RESET pin
_SPI_DC = 1 ' DC (SS) Data/Command pin
_SPI_CS = 1 ' CS Chip Select pin
'_SPI_SCK = 1 ' SCK as output
'_SPI_SDO = 1 ' SDO as output -> SDI
' Configure SPI operation mode
Select Case mode
Case 0
SSP1CON1.4 = 0 ' CKP = 0
SSP1STAT.6 = 1 ' CKE = 1
Case 1
SSP1CON1.4 = 0 ' CKP = 0
SSP1STAT.6 = 0 ' CKE = 0
Case 2
SSP1CON1.4 = 1 ' CKP = 1
SSP1STAT.6 = 1 ' CKE = 1
Case 3
SSP1CON1.4 = 1 ' CKP = 1
SSP1STAT.6 = 0 ' CKE = 0
EndSelect
SSP1CON1 = SSP1CON1 | speed
End Proc
The SMP bit is not currently implemented in the function, by default it is = 0.Hi D,
I've been looking though your CODEs as best as I can, trying to understand how you set up the SPI settings.
I think I've found which MODE you use: MODE 2 = CKP=1 and CKE=1
So far I haven't been able to find the SMP setting?
SSPSTAT.7
Can you clarify these 3x settings please?
Cheers, C.
Code:'Example: Call _SPI1_Init(_SPI_MODE0, _SPI_MASTER_SPEED1 | _SPI_ENABLE) 'CLK 4Mhz (64Mhz) Proc _SPI1_Init(mode As Byte, speed As Byte) ' Configure SPI pins ConfigPin _SPI_SCK = Output ' SCK as output ConfigPin _SPI_SDI = Input ' SDI as input ConfigPin _SPI_SDO = Output ' SDO as output ConfigPin _SPI_RST = Output ' RESET as output ConfigPin _SPI_DC = Output ' DC (SS) Data/Command pin as output ConfigPin _SPI_CS = Output ' CS Chip Select pin ' Estado inicial de los pin _SPI_RST = 1 ' RST RESET pin _SPI_DC = 1 ' DC (SS) Data/Command pin _SPI_CS = 1 ' CS Chip Select pin '_SPI_SCK = 1 ' SCK as output '_SPI_SDO = 1 ' SDO as output -> SDI ' Configure SPI operation mode Select Case mode Case 0 SSP1CON1.4 = 0 ' CKP = 0 SSP1STAT.6 = 1 ' CKE = 1 Case 1 SSP1CON1.4 = 0 ' CKP = 0 SSP1STAT.6 = 0 ' CKE = 0 Case 2 SSP1CON1.4 = 1 ' CKP = 1 SSP1STAT.6 = 1 ' CKE = 1 Case 3 SSP1CON1.4 = 1 ' CKP = 1 SSP1STAT.6 = 0 ' CKE = 0 EndSelect SSP1CON1 = SSP1CON1 | speed End Proc
Hi D,The SMP bit is not currently implemented in the function, by default it is = 0.
Please note that I am expanding or completing the function as needed, for the moment all the devices I have tested SMP = 0 is correct.
Details of the 3 mentioned parameters:
CKP (Clock Polarity) – bit in the SSPCON1 register
Controls the idle state level of the clock (SCK).
CKP = 1 → the clock is high when idle.
CKP = 0 → the clock is low when idle.
CKE (Clock Edge) – bit 6 of the SSPSTAT register
Determines on which clock edge the data is transmitted.
CKE = 1 → Data is transmitted on the falling edge (from 1 to 0).
CKE = 0 → Data is transmitted on the rising edge (from 0 to 1).
The direction of transmission (rising or falling) also depends on the value of CKP. Both CKP and CKE bits must be considered together to define the SPI mode.
Hi D,
Ok, thanks.
I've tried all of the 3x setting combinations now, and still find SPI errors.
I wonder if it depends on the source of the TFT screens, whether or not there are errors or not?
C.
Hi D,I don't know, as I haven't been able to duplicate the problem.
Hi I,Hi C.. here are two screen shots one on the ILI9341 datasheet and one from the pick
pic
View attachment 149471
ILI9341 datasheet
View attachment 149472
It looks to me like mode 2 CKP = 0 and CKE = 1 is what they want on the ILI. The sample is in the middle of data
The st7789 however is sample after clock thats why the ST7789 is better on mode 3..
There shouldn't be any difference in the microcontrollers because the packaging is different.Hi D,
I think that you use 18F46K22, but do you also use 18F46K20, with no problems?
Also are they SMD or TTH?
C.
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?