|
|
View previous topic :: View next topic |
Author |
Message |
PICoHolic
Joined: 04 Jan 2005 Posts: 224
|
PIC18F87J50 USART1 & 2 baud rate & I2C master (HW) |
Posted: Thu Apr 10, 2008 1:17 am |
|
|
Hey,
Code: |
// Configuration Bits
#FUSES NOWDT
#FUSES PLL3
#FUSES NOSTVREN
#FUSES NOCPUDIV
#FUSES H4_SW
#FUSES NOXINST
// Clock configuration: 12MHz crystal
#use delay(clock=48000000)
#use rs232(baud=115200,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8, STREAM = SYN, UART1)
#use rs232(baud=38400,parity=N,xmit=PIN_G1,rcv=PIN_G2,bits=8, STREAM = CDR , UART2)
#use i2c(Master,Slow=100000,sda=PIN_C4,scl=PIN_C3, FORCE_SW) |
Listing:
Code: |
00D96: MOVLW 08
00D98: MOVWF 01
00D9A: MOVLW 11
00D9C: MOVWF 00
00D9E: DECFSZ 00,F
00DA0: BRA 0D9E
00DA2: BCF F8B.3
00DA4: BCF F94.3
00DA6: MOVLW 11
00DA8: MOVWF 00
00DAA: DECFSZ 00,F
00DAC: BRA 0DAA
00DAE: MOVLB 1
00DB0: RLCF x41,F
00DB2: BCF F8B.4
00DB4: BTFSC FD8.0
00DB6: BSF F94.4
00DB8: BTFSS FD8.0
00DBA: BCF F94.4
00DBC: BSF F94.3
00DBE: BTFSS F82.3
00DC0: BRA 0DBE
00DC2: DECFSZ 01,F
00DC4: BRA 0DC8
00DC6: BRA 0DCC
00DC8: MOVLB 0
00DCA: BRA 0D9A
00DCC: MOVLW 11
00DCE: MOVWF 00
00DD0: DECFSZ 00,F
00DD2: BRA 0DD0
00DD4: BCF F8B.3
00DD6: BCF F94.3
00DD8: NOP
00DDA: BSF F94.4
00DDC: MOVLW 11
00DDE: MOVWF 00
00DE0: DECFSZ 00,F
00DE2: BRA 0DE0
00DE4: MOVLW 11
00DE6: MOVWF 00
00DE8: DECFSZ 00,F
00DEA: BRA 0DE8
00DEC: BSF F94.3
00DEE: BTFSS F82.3
00DF0: BRA 0DEE
00DF2: CLRF 01
00DF4: MOVLW 11
00DF6: MOVWF 00
00DF8: DECFSZ 00,F
00DFA: BRA 0DF8
00DFC: BTFSC F82.4
00DFE: BSF 01.0
00E00: BCF F8B.3
00E02: BCF F94.3
00E04: BCF F8B.4
00E06: BCF F94.4
00E08: MOVLB 0
00E0A: RETLW 00
*
|
For USART1 the actual baud is greater than 115200
I didnt test for UART2 yet.
Also HW I2C stalls, i had to do it by SW!
!? |
|
|
Matro Guest
|
|
Posted: Thu Apr 10, 2008 1:42 am |
|
|
Quote: |
For USART1 the actual baud is greater than 115200
|
What does it mean?
What is the difference?
You wrote #use delay(clock=48000000)
But is the HW UART driven by such a clock?
Check that the baudrate is correct according to the .lst file and the datasheet.
Matro. |
|
|
PICoHolic
Joined: 04 Jan 2005 Posts: 224
|
|
Posted: Thu Apr 10, 2008 2:01 am |
|
|
Quote: |
What does it mean?
What is the difference?
|
PIC18F87J50 has 2 UARTs & 2 MSSPs
The actual Baud rate on UART1 is ~2.7 times faster than 115200.
The compiler should calculate the baud rate value according to the actual system clock which is 48MHz (12MHz internally).
I'm using a C compiler, why would i need to go to the listing and check for compiler bugs everytime!?!?
It's a real waste of TIME that i dont have much of it.
That's the main idea. So the purpose of my post is to find someone that has already done it instead of waisting time tracing the listing
10x
Last edited by PICoHolic on Thu Apr 10, 2008 3:47 am; edited 1 time in total |
|
|
Matro Guest
|
|
Posted: Thu Apr 10, 2008 2:08 am |
|
|
I can't say more.
But just for test, if you replace #FUSES PLL3 by PLL1.
Is it now correct?
Matro. |
|
|
PICoHolic
Joined: 04 Jan 2005 Posts: 224
|
|
Posted: Thu Apr 10, 2008 3:46 am |
|
|
I cannot, since the PLL input needs a fixed 4MHz frequency i.e: PLL3 is a division by 3 --> 12/3 = 4MHz
Also the CPU divider is set to 1 (no division) --> 48MHz system OSC --> 48/4=12MHz internal OSC
Thanks |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|