|
|
View previous topic :: View next topic |
Author |
Message |
costamlucas
Joined: 01 Oct 2012 Posts: 3
|
USART problem on PIC18F67K22 |
Posted: Mon Oct 01, 2012 12:09 pm |
|
|
Hy guys, we are migrating a system from 18F46K22 to 187F67K22 and we're having comm issues on that.
I just started testing the communications like EUSART and here is the point that starts my problem.
I compiled the simple code below to print at terminal the message to validate that my EUSART 1 & 2 are working fine but always is shown inconsistent info on terminal.
I contacted with CCS Support and we tried a lot of configs #FUSES and changes in code but it still don't work fine.
To exclude any circuit design error we compiled a code in C18 Compiler and it works very well, printing on terminal the message without none inconsistent character.
Can anyone help me with this?
I'm setting these #FUSES but I don't have certainty that they are ok.
Please I need help, can anyone put hands on work with me?
Waiting for a help.
Below follow the code:
dsde.h
________________
Code: |
#include <18F67K22.h>
#device adc=8
#FUSES NOWDT //No Watch Dog Timer
#FUSES WDT128 //Watch Dog Timer uses 1:128 Postscale
#FUSES HS //High speed Osc (> 4mhz for PCM/PCH) (>10mhz for PCD)
#FUSES NOPROTECT //Code not protected from reading
#FUSES BROWNOUT //Reset when brownout detected
#FUSES BORV20 //Brownout reset at 2.0V
#FUSES NOPUT //No Power Up Timer
#FUSES NOCPD //No EE protection
#FUSES NOSTVREN //Stack full/underflow will not cause reset
#FUSES NODEBUG //No Debug mode for ICD
#FUSES NOWRT //Program memory not write protected
#FUSES NOWRTD //Data EEPROM not write protected
#FUSES NOIESO //Internal External Switch Over mode disabled
#FUSES NOFCMEN //Fail-safe clock monitor disabled
#FUSES NOWRTC //configuration not registers write protected
#FUSES NOWRTB //Boot block not write protected
#FUSES NOEBTR //Memory not protected from table reads
#FUSES NOEBTRB //Boot block not protected from table reads
#FUSES NOCPB //No Boot Block code protection
#FUSES NOMCLR //Master Clear pin used for I/O
#FUSES NOXINST //Extended set extension and Indexed Addressing mode disabled (Legacy mode)
#FUSES NODELAYINTOSC
#FUSES VREGSLEEP
#FUSES SOSC_DIG
#FUSES RTCOSC_INT
#FUSES INTRC_LP
#FUSES NOPLLEN
#FUSES ZPBORM
#FUSES WDT_SW
#FUSES WDT1048576
#use delay(clock=20000000)
#use rs232(baud=2400,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8,stream=USART1)
#use rs232(baud=2400,parity=N,xmit=PIN_G1,rcv=PIN_G2,bits=8,stream=USART2)
#fuses 1=0xC215
|
dsde.c
_____________
Code: | #include <dsde.h>
#define LED PIN_E1
void main()
{
setup_adc_ports(NO_ANALOGS|VSS_VDD);
setup_adc(ADC_CLOCK_DIV_2|ADC_TAD_MUL_0);
setup_spi(SPI_SS_DISABLED);
setup_wdt(WDT_OFF);
setup_timer_0(RTCC_INTERNAL);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_timer_4(T4_DISABLED,0,1);
setup_ccp1(CCP_OFF);
setup_comparator(NC_NC_NC_NC);// This device COMP currently not supported by the PICWizard
printf(EUSART1,"Testing PIC18F67K22 EUSART1...\r\n");
while(true){
printf(EUSART1,"While...\r\n");
output_low(LED);
delay_ms(1000);
output_high(LED);
delay_ms(1000);
}
}
| _________________ Nice regards,
Lucas. |
|
|
n-squared
Joined: 03 Oct 2006 Posts: 99
|
|
Posted: Mon Oct 01, 2012 1:35 pm |
|
|
You did not explain exactly the nature of the problem in output.
Try adding the following line after #device adc=8:
Code: |
#device pass_strings=in_ram
|
_________________ Every solution has a problem. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19546
|
|
Posted: Mon Oct 01, 2012 2:56 pm |
|
|
Several comments apply though:
setup_spi(SPI_SS_DISABLED);
This line _enables_ the SPI, and disables slave select. Is this what you want?. The line to disable the SPI, is:
setup_spi(FALSE);
Then you have fuses:
#FUSES HS
#FUSES INTRC_LP
Two different oscillators selected. You must only ever select _one_ fuse from those controlling the primary oscillator.
Then your syntax for PRINTF is wrong.
The send to a stream, you use _FPRINTF_.
I'm surprised it works at all....
Best Wishes |
|
|
costamlucas
Joined: 01 Oct 2012 Posts: 3
|
|
Posted: Thu Oct 04, 2012 9:58 am |
|
|
n-squared wrote: | You did not explain exactly the nature of the problem in output.
Try adding the following line after #device adc=8:
Code: |
#device pass_strings=in_ram
|
|
Hy, thanks for your comment. But I have problem at transmiting data through EUSART 1 & 2. I didn't understand what this line sets.
Can you explain? _________________ Nice regards,
Lucas. |
|
|
costamlucas
Joined: 01 Oct 2012 Posts: 3
|
|
Posted: Thu Oct 04, 2012 10:01 am |
|
|
Ttelmah wrote: | Several comments apply though:
setup_spi(SPI_SS_DISABLED);
This line _enables_ the SPI, and disables slave select. Is this what you want?. The line to disable the SPI, is:
setup_spi(FALSE);
Then you have fuses:
#FUSES HS
#FUSES INTRC_LP
Two different oscillators selected. You must only ever select _one_ fuse from those controlling the primary oscillator.
Then your syntax for PRINTF is wrong.
The send to a stream, you use _FPRINTF_.
I'm surprised it works at all....
Best Wishes |
Hy,
I really didn't understand your comment. I'm having a problem with ESUART 1& 2 (Serial) and not with SPI.
Can you help me?
Best regards. _________________ Nice regards,
Lucas. |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Thu Oct 04, 2012 2:54 pm |
|
|
costamlucas wrote: | Ttelmah wrote: | Several comments apply though:
setup_spi(SPI_SS_DISABLED);
This line _enables_ the SPI, and disables slave select. Is this what you want?. The line to disable the SPI, is:
setup_spi(FALSE);
Then you have fuses:
#FUSES HS
#FUSES INTRC_LP
Two different oscillators selected. You must only ever select _one_ fuse from those controlling the primary oscillator.
Then your syntax for PRINTF is wrong.
The send to a stream, you use _FPRINTF_.
I'm surprised it works at all....
Best Wishes |
Hy,
I really didn't understand your comment. I'm having a problem with ESUART 1& 2 (Serial) and not with SPI. | We do like small programs. Your's can be made smaller. When you post a larger program that shows more than the relevant code it is possible we spot an error and tell you about it. With the SPI setup error here it is very likely that RC5 (SDO) on your chip is enabled as output and not working as you intended it to do.
Be happy with the bugfix.
Instead of only complaining it would help when you give useful feedback.
1) Ttelmah gave you a suggestion to fix your wrong clock fuses. Did you fix this and what are the results?
2) You say you see ' inconsistent info'. As N-Squared pointed out we don't understand what you mean. Are characters missing? Are all characters garbage? Are only a few characters garbage? Something different?
3) _ALWAYS_ post your compiler version number.
4) Remove the line: Perhaps this line is correct, but it conflicts with the earlier settings and is difficult to read. |
|
|
|
|
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
|