Faster? 28X1 20mhz or 28X2 40mhz

retepsnikrep

Senior Member
Which is faster and by how much?

I am assuming 5v devices not the 64mhz X2.

Thanks

Looking at a 28X1 at 20mhz but need 9600,8,E,1 any thoughts on initialising the 28X1 ASUART for 20mhz to work at 9600 baud.

I have been using an 18X with the asuart code at 8mhz but it's just not quite fast enough to keep up with reception. It does work so i'm reasonably happy with the code below.

Code:
`Constants


	; Ports	

	SYMBOL Shadow_TRISB = $AE


	; Registers			PICAXE-18X / 16F88 SFR Definitions 

        SYMBOL  PIR1        = $0C
        SYMBOL  RCSTA       = $18
        SYMBOL  TXREG       = $19
        SYMBOL  RCREG       = $1A
        SYMBOL  TXSTA       = $98
        SYMBOL  SPBRG       = $99

        ; TXSTA Bit Masks

        SYMBOL  CSRC        = %10000000
        SYMBOL  TX9         = %01000000
        SYMBOL  TXEN        = %00100000
        SYMBOL  SYNC        = %00010000
        SYMBOL  BRGH        = %00000100
        SYMBOL  TRMT        = %00000010
        SYMBOL  TX9D        = %00000001

        SYMBOL  CSRC_BIT    = bit15
        SYMBOL  TX9_BIT     = bit14
        SYMBOL  TXEN_BIT    = bit13
        SYMBOL  SYNC_BIT    = bit12
        SYMBOL  BRGH_BIT    = bit10
        SYMBOL  TRMT_BIT    = bit9
        SYMBOL  TX9D_BIT    = bit8

        ; RCSTA Bit Masks

        SYMBOL  SPEN        = %10000000
        SYMBOL  RX9         = %01000000
        SYMBOL  SREN        = %00100000
        SYMBOL  CREN        = %00010000
        SYMBOL  ADDEN       = %00001000
        SYMBOL  FERR        = %00000100
        SYMBOL  OERR        = %00000010
        SYMBOL  RX9D        = %00000001

        SYMBOL  SPEN_BIT    = bit15
        SYMBOL  RX9_BIT     = bit14
        SYMBOL  SREN_BIT    = bit13
        SYMBOL  CREN_BIT    = bit12
        SYMBOL  ADDEN_BIT   = bit11
        SYMBOL  FERR_BIT    = bit10
        SYMBOL  OERR_BIT    = bit9
        SYMBOL  RX9D_BIT    = bit8

	; PIR1 Bit Masks

        SYMBOL  ADIF        = %01000000
        SYMBOL  RCIF        = %00100000
        SYMBOL  TXIF        = %00010000
        SYMBOL  SSPIF       = %00001000
        SYMBOL  CCP1IF      = %00000100
        SYMBOL  TMR2IF      = %00000010
        SYMBOL  TMR1IF      = %00000001

        SYMBOL  ADIF_BIT    = bit14
        SYMBOL  RCIF_BIT    = bit13
        SYMBOL  TXIF_BIT    = bit12
        SYMBOL  SSPIF_BIT   = bit11
        SYMBOL  CCP1IF_BIT  = bit10
        SYMBOL  TMR2IF_BIT  = bit9
        SYMBOL  TMR1IF_BIT  = bit8


	symbol SPBRG_INIT = 12         	;9600 baud @ 8MHz
Peter
 

hippy

Ex-Staff (retired)
Which is faster and by how much?
The 28X2 at 40MHz is faster than the 28X1 at 20MHz but I don't have an exact figure. The firmware runs twice as fast but also has to do more so the outcome is faster but not necessarily twice as fast. Performance will depend on the particular code you are using.

There is also the 20X2 which can run at 64MHz at 5V.

The 20X2, 28X1 and 28X2 have background high-speed serial receive built into firmware so it's not required to poll the AUSART for data as required with the 18X. The 20X2, 28X1 and 28X2 only has to process the data quicker than it arrives to prevent the receive buffer from overflowing so any would probably be suitable. The 28X2 has a 1024 byte receive buffer, the 28X1 and 20X2 have 128 bytes.

Which is most suitable depends on the nature of what you are doing; how much data arrives, how often and how much processing you need to do on that data. For large data packets the 28X2 has the edge, for a lot of processing the 20X2 has the edge.

Added : I'll have to get back to you on how to configure for 9600,E,8,1
 
Last edited:

retepsnikrep

Senior Member
There is also the 20X2 which can run at 64MHz at 5V.
Interesting I had forgotten that!!

The 20X2, 28X1 and 28X2 have background high-speed serial receive built into firmware so it's not required to poll the AUSART for data as required with the 18X. The 20X2, 28X1 and 28X2 only has to process the data quicker than it arrives to prevent the receive buffer from overflowing so any would probably be suitable. The 28X2 has a 1024 byte receive buffer, the 28X1 and 20X2 have 128 bytes.
Can the background serial receive you mention do 9600,8,E,1 I believe the other picaxes could not do even parity unless using the fancy ASUART code?
 

hippy

Ex-Staff (retired)
I believe it should be possible to use 9600,E,8,1; probably just a matter of using HSERSETUP then POKESFR to configure the AUSART as required, but can't off-hand say what the actual code would need to be,
 

hippy

Ex-Staff (retired)
"probably just a matter of using HSERSETUP then POKESFR to configure the AUSART as required, but can't off-hand say what the actual code would need to be"
 

Technical

Technical Support
Staff member
Parity is not supported in the PIC hardware, in theory if writing in assembler you could 'fake' it by using a 9th bit amd manually calculating what the parity should be be. But this is not possible using the PICAXE system. The only parity option supported on PICAXE is N - none!
 
Last edited:

retepsnikrep

Senior Member
I've been faking it with the 18X and ASUART code TXD/RXD I'll have to do the same with the 20X2, the higher speed over the 8mhz 18X will hopefully allow me to process my data as well. Thanks anyway.
 

hippy

Ex-Staff (retired)
Sorry, but it wasn't entirely clear what you were fully doing as the code example was just a list of Symbol definitions.

Faking it as with the 18X should technically be possible on the X1 and X2 PICAXE's but the caveat is that the internal SFR's be accessible using PICAXE commands. They don't appear to be on the 28X1 but possibly on the 20X2 or 28X2 - Minimal testing suggests they are.
 
Last edited:
Top