View previous topic :: View next topic |
Author |
Message |
pyclan
Joined: 13 Dec 2005 Posts: 48 Location: Russia
|
Posted: Fri Aug 01, 2014 7:19 am Post subject: Xmega USART in SPI MODE - Please Help! |
|
|
Hi everyone!
Please Help with Example settings COM2 (PORTC.7 PORTC.6) in MASTER SPI MODE.
And an example of commands PRINT and INPUT.
Not found examples this mode.
Thanks,
Ruslan.
(BASCOM-AVR version : 2.0.7.7 ) |
|
Back to top |
|
|
Visovian
Joined: 31 Oct 2007 Posts: 584 Location: Czech
|
Posted: Fri Aug 01, 2014 9:14 pm Post subject: |
|
|
Quote: | Please Help with Example settings COM2 (PORTC.7 PORTC.6) in MASTER SPI MODE. | This makes little sense. SPI mode has nothing to do with COM port.
What do you want to do?
With what Avr type? |
|
Back to top |
|
|
MWS
Joined: 22 Aug 2009 Posts: 2262
|
Posted: Sat Aug 02, 2014 10:54 am Post subject: |
|
|
Visovian wrote: | This makes little sense. SPI mode has nothing to do with COM port. |
Manual XMega A
21. USART
21.10 USART in Master SPI Mode
Quote: | With what Avr type? |
Quote: | Post subject: Xmega USART in SPI MODE |
Exact type of XMega makes not much difference.
I've used it to drive WS2811 via DMA, code to find here in forum. |
|
Back to top |
|
|
Paulvk
Joined: 28 Jul 2006 Posts: 1257 Location: SYDNEY
|
Posted: Sun Aug 03, 2014 12:16 am Post subject: |
|
|
Devices like the Mega1284 also have Uarts with SPI mode it would be nice not to switch from SD card to Wiznet W5100 but Bascom does not support this yet.
Regards Paul |
|
Back to top |
|
|
pyclan
Joined: 13 Dec 2005 Posts: 48 Location: Russia
|
Posted: Sun Aug 03, 2014 7:44 am Post subject: |
|
|
Hi All!
Thanks MWS for the tip!
Paulvk wrote: | Devices like the Mega1284 also have Uarts with SPI mode it would be nice not to switch from SD card to Wiznet W5100 but Bascom does not support this yet.
Regards Paul |
BASCOM-AVR Help Reference
Version 2.0.7.7 document build 52
Section - CONFIG COMx
Remarks Xmega
mode:
The USART mode, this can be :
- ASYNCHRONEOUS or 0 (default) for asynchronous operation.
- SYNCHRONEOUS or 1 , for synchronous operation.
- IRDA or IRCOM for IRDA operation
- SPI or MSPI for operation as SPI controller
This is not supported?
Mark it works without asm insertion?
Description mode and have no examples.
Thank you all for your help,
Ruslan. |
|
Back to top |
|
|
MWS
Joined: 22 Aug 2009 Posts: 2262
|
Posted: Sun Aug 03, 2014 12:47 pm Post subject: |
|
|
Code: | $Regfile = "xm128a1def.dat"
$Crystal = 32000000
$hwstack = 32
$swstack = 8
$framesize = 24
Config Osc = Enabled , 32mhzosc = Enabled
Config Sysclock = 32mhz
Config Com1 = 250000 , mode = SPI , Databits = 8
'Config Com2 = 250000 , mode = SPI , Databits = 8
'Open "com2:" For Binary As #1
Dim B As Byte
B = 1
Do
Printbin B
'Printbin #1 , B
Incr B
Waitms 500
Loop
'Close #1 |
|
|
Back to top |
|
|
pyclan
Joined: 13 Dec 2005 Posts: 48 Location: Russia
|
Posted: Sun Aug 03, 2014 5:28 pm Post subject: |
|
|
Print works.
And how to read?
INPUT ???? |
|
Back to top |
|
|
MWS
Joined: 22 Aug 2009 Posts: 2262
|
Posted: Mon Aug 04, 2014 9:09 am Post subject: |
|
|
To get a byte from a SPI-slave, the master needs to send a byte.
By analyzing the code created for Inputbin, I can say it does not shift anything out, so it looks it is not implemented yet.
It may work to send out one byte via Printbin and after fetch one byte via Inputbin.
Receiving larger chunks of data will be slow this way and care has to be taken to flush the UART-MSPI input buffer before.
There's no such functionality like in SPI (see Config SPIx), at least in version 2.0.7.7, so if you like to use UART-MSPI more efficiently, you need to write your own functions. |
|
Back to top |
|
|
|