14M2 vs PIC16F1825

GrahamGo

Senior Member
The website says that the 14M2 datasheet is the PIC16F1825. But I see the 14M2 has ports C0-5 and B0-5, whereas the 1825 has ports C0-5 and A0-5 meaning that the pins are named differently and in different positions.

Then I looked at the 18M2 = PIC16F1847, and compared it to "PICaxe 18M2 SFR Data Ver_A.pdf" from here :- http://www.picaxeforum.co.uk/showthread.php?11514-PICAXE-Memory-Map-and-SFR-Details-Chart/page2 Post# 13. - nice chart.

I notice that SFR locations differ ie. SSP1CON1 in the 1847 datasheet is at $215 but in the "PICaxe 18M2 SFR Data Ver_A.pdf" it is at $95.

So I am confused on several counts.

1. Why the different port/pin designations?
2. I don't understand SFR and cannot find out how correctly calculate the Bank# etc. ie. how did $215 become $95?
3. Is my coding attempt anywhere close?


I am interested in trying to use the hardware SPI port. Here is the code as of now. I suppose that I have learnt quite a bit doing this exercise, but it is coming to a frustrating ending. So any guidance and hints will be gratefully accepted.

Code:
' initialize the SPI module to have idle for clock low, send at middle of clock pules
' transmit on idle-active, use clock/64
' also needs to set the SS and SPI pins to proper outputs
 
 
' symbol OSCTUNE = $98
symbol SSP1BUF  = $91  ' or $211 ??
symbol SSP1STAT = $94 ' $214
symbol SSP1CON1 = $95 ' $215
symbol APFCON0  = $11D
symbol APFCON1  = $11E

symbol TRIS_A = $8C
symbol TRIS_C = $8E

Main:
	Gosub InitSPI
'	debug
	Gosub WriteToSPI
'	debug
	Goto main
 
InitSPI:
' B3 SCK0 output, B4 SDI input, B5 SDO output     
		   '76543210        
 let dirsB =	%11111111 	' set port pin directions
 ' let dirsC =	%11011111 
 
 b1 = 0
 		pokesfr b1,SSP1CON1 	'turn off module, in case it was on
 		pokesfr b1,SSP1STAT		'send at middle of clock, transmit on idle->active
 b1 = %00100010
    pokesfr b1,SSP1CON1		'enable MSSP, idle is low,clock/64
 b1 = %0
'    pokesfr b1,APFCON1		'alternate pin config
 return
 

WriteToSPI:
     b1 = $55
     pokesfr b1,SSP1BUF
     pause 50
     return
 

westaust55

Moderator
With respect to the SFR's have a read of the PICAXE manual 2 PEEKSRF and POKESRF commands which explain how the SRF's that you are given access to are re-mapped.

With respect to the naming of pins, Rev Ed have tried to be consistent in the PICAXE scheme across many chips.
Better to read the PICAXE manuals and use the PIC datasheets as supporting information but accept there is remapping of registers and pins.
 

hippy

Ex-Staff (retired)
2. I don't understand SFR and cannot find out how correctly calculate the Bank# etc. ie. how did $215 become $95?
The translation from PICmicro SFR address to PICAXE SYMBOL definition is as shown in the attachment ...
 

Attachments

GrahamGo

Senior Member
Guy's thank you very much for the pointers. Some I plain missed (bleary eyes) and others I didn't understand, I still have to get my head around the pin remapping. I am still in question mode, but hopefully one day in the future like you guys be able to contribute rather than just take. I have been able to get the hardware SPI going and will start a new thread with a more appropriate title - thanks again!
 
Top