PDA

View Full Version : 4 mhz program speed in pic 18f4550 please



dala01
- 12th December 2011, 00:12
I want to make a serial communication --- 18f4550 and max6675 ---

but max6675 demand 4,3 mhz max to have the correct communication

how can i run my program on pic18f4550 at 4 Mhz

(the pic is also connected to pc via usb) ,the probleme is how change this default configuration to have programme running speed at 4 mhz and keep usb communication at 48Mhz.

__CONFIG _CONFIG1L, _PLLDIV_5_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L
__CONFIG _CONFIG1H, _FOSC_HSPLL_HS_1H
__CONFIG _CONFIG2H, _WDT_ON_2H & _WDTPS_512_2H
__CONFIG _CONFIG3H, _PBADEN_OFF_3H
__CONFIG _CONFIG4L, _LVP_OFF_4L & _ICPRT_OFF_4L & _XINST_OFF_4L

mackrackit
- 12th December 2011, 00:55
but max6675 demand 4,3 mhz max to have the correct communication
Nope, the 6675 will work just fine with a MCU running at 48MHz.

Here are some snippets.


DEFINE OSC 48
@ __CONFIG _CONFIG1L, _PLLDIV_1_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L
@ __CONFIG _CONFIG1H, _FOSC_HSPLL_HS_1H
@ __CONFIG _CONFIG2H, _WDT_OFF_2H & _WDTPS_512_2H
@ __CONFIG _CONFIG3H, _PBADEN_OFF_3H & _MCLRE_OFF_3H
@ __CONFIG _CONFIG4L, _LVP_OFF_4L & _ICPRT_OFF_4L &_XINST_OFF_4L

'Alias pins - MAX6675 temp sensor
MXSCLK VAR PORTA.0 'Clock
MXCS VAR PORTA.1 'Chip Select
MXSO VAR PORTA.2 'Serial out


'Read the 6675
MXCS = 0 'Chip select low
shiftin MXSO, MXSCLK, 0, [MXTemp\16] 'read the data to MXTemp
MXCS = 1 'Chip select high
TempC = MXtemp >> 5 'right shift the data 5 places to get degrees C (Read the Data sheet)
TempF = ABS(TempC) */ 461
TempF = TempF + 32


I also deleted your other post as it is a duplicate of this one. No need to double post.

dala01
- 12th December 2011, 11:05
thank you very much dude for your replay ...

but my problem is when learning the data sheet of max6675 i saw in specifecation that frequency maximum to work is 4.3

see datasheet max6675 page 3 : http://datasheets.maxim-ic.com/en/ds/MAX6675.pdf

(so if osc 48 mhz , mxs0 will have 48 mhz speed ?? but normaly it will not exeed 4.3mhz)

i have't problem with programmation but only the oscillation appropriate for max6675

I need help please .......

mackrackit
- 12th December 2011, 12:10
The data sheet is talking about the timing for the serial communications. The timing for the SHIFTIN command is taken care of in the software. Take a look at the PBP manual.

The code I posted is from a working project.

dala01
- 12th December 2011, 12:32
That realy helpful !

thanks very very much mackrackit .