View previous topic :: View next topic |
Author |
Message |
lucasromeiro
Joined: 27 Mar 2010 Posts: 167
|
|
Posted: Sat Nov 24, 2012 9:28 am |
|
|
Mike Walne wrote: | Now you're confusing me
Quote: | All other functions work correctly.
I tested the code posted above and still nothing worked! |
You also seem to be saying that the crystals never oscillate.
Please DO NOT KEEP REFERRING to PROTEUS. It's not helpful.
So.
On a REAL board tell us EXACTLY what works and what does not.
Mike |
Everything I said is true regarding the plates.
just did a test on proteus to see the result.
when told that the crystals do not vibrate, this is the real board. no information that I spent here was the proteus, commented that only works in proteus. |
|
 |
Mike Walne
Joined: 19 Feb 2004 Posts: 1785 Location: Boston Spa UK
|
|
Posted: Sat Nov 24, 2012 9:59 am |
|
|
Quote: | Everything I said is true regarding the plates. |
I'm not doubting your honesty. I do believe that what you say is true.
This thread is going nowhere, fast.
What I'm after, is a consice summary of the current situation.
For example, with minimal code:-
Can you make an LED toggle at the correct rate with the internal oscillator?
Can you send data at the correct rate with the UART?
Can you see the HF oscillator run?
.......................
Etc.
In other words:-
Can you test each peripheral one at a time?
Do they operate with correct amplitude and frequency?
Mike
And please do not mention Proteus again. |
|
 |
lucasromeiro
Joined: 27 Mar 2010 Posts: 167
|
|
Posted: Sat Nov 24, 2012 10:28 am |
|
|
Mike Walne wrote: | Quote: | Everything I said is true regarding the plates. |
I'm not doubting your honesty. I do believe that what you say is true.
This thread is going nowhere, fast.
What I'm after, is a consice summary of the current situation.
For example, with minimal code:-
Can you make an LED toggle at the correct rate with the internal oscillator?
Can you send data at the correct rate with the UART?
Can you see the HF oscillator run?
.......................
Etc.
In other words:-
Can you test each peripheral one at a time?
Do they operate with correct amplitude and frequency?
Mike
And please do not mention Proteus again. |
Sorry if I expressed myself badly, I am Brazilian and I am using a translator.
Answering your questions:
Yes I can do a light flashes on the correct frequency.
Yes I can send and receive data through the two serial I have.
Yes, the master oscillator (20Mhz) works perfectly and I can read your frequency with the oscilloscope, something that I can not with Crystal rtc.
The rtc internal functions normally with internal crystal.
Usr can usually an lcd 20x4.
Use reading and writing the EEPROM normally
readings and outputs function normally.
Apparently everything works correctly.
I think I have to configure something to make the clock work.
Some register, do not know.
Does anyone have this pic and could do the test with the code I posted to see the result?
Even if it is in another board, because if someone is successful, it may be my compiler, it may be something specific to my board, or even any configuration. |
|
 |
Ttelmah
Joined: 11 Mar 2010 Posts: 19826
|
|
Posted: Sat Nov 24, 2012 12:00 pm |
|
|
Have you actually tried with the line:
setup_oscillator(OSC_SOSC_ON);
added to the code suggested by andrew?.
This line is needed by some compiler versions, setting the 'go' bit for the oscillator.
When I used the secondary oscillator, it was quite a few compiler versions ago (CCS unfortunately does change how such things work), but this line was needed.
Best Wishes |
|
 |
lucasromeiro
Joined: 27 Mar 2010 Posts: 167
|
|
Posted: Sat Nov 24, 2012 12:06 pm |
|
|
Ttelmah wrote: | Have you actually tried with the line:
setup_oscillator(OSC_SOSC_ON);
added to the code suggested by andrew?.
This line is needed by some compiler versions, setting the 'go' bit for the oscillator.
When I used the secondary oscillator, it was quite a few compiler versions ago (CCS unfortunately does change how such things work), but this line was needed.
Best Wishes |
Thanks for the tip,
I had previously tested with this line, however this did not last test I put it!
Good idea!
this is the first test that I will do when I go to work.
What other possibilities for me to test? |
|
 |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sat Nov 24, 2012 12:52 pm |
|
|
The basic problem is you have to run all replies through a translator
and so you don't see or understand many of the replies. For example:
andrewg said:
Quote: |
Let me assure you that without them it is definitely NOT going to work,
and without them you're wasting everyones time.
|
Then later you (lucasromeiro) reply:
Quote: | but even without the capacitors should work, right?
|
You ignored his direct statement that capacitors are required.
This is why there is no progress in solving the RTC problem. |
|
 |
lucasromeiro
Joined: 27 Mar 2010 Posts: 167
|
|
Posted: Sat Nov 24, 2012 1:04 pm |
|
|
PCM programmer wrote: | The basic problem is you have to run all replies through a translator
and so you don't see or understand many of the replies. For example:
andrewg said:
Quote: |
Let me assure you that without them it is definitely NOT going to work,
and without them you're wasting everyones time.
|
Then later you (lucasromeiro) reply:
Quote: | but even without the capacitors should work, right?
|
You ignored his direct statement that capacitors are required.
This is why there is no progress in solving the RTC problem. |
I agree it is a problem of communication exists.
but well observed responses and later I did and I put the capacitors, as shown here.
the results have not changed.
you could test it on board?
thank you |
|
 |
lucasromeiro
Joined: 27 Mar 2010 Posts: 167
|
|
Posted: Mon Nov 26, 2012 11:17 am |
|
|
I will test in 30 minutes |
|
 |
lucasromeiro
Joined: 27 Mar 2010 Posts: 167
|
HEPL PLEASE |
Posted: Mon Nov 26, 2012 12:29 pm |
|
|
good afternoon!
I just test the code putting the line:
setup_oscillator (OSC_SOSC_ON);
but nothing changed.
Can someone help me? |
|
 |
lucasromeiro
Joined: 27 Mar 2010 Posts: 167
|
|
Posted: Mon Nov 26, 2012 1:58 pm |
|
|
hello, did several tests taking and putting fuses, tried changing the version of the compiler that a friend Tiha, tried by the fuses through the mplab ....
But nothing worked.
The options are running out. |
|
 |
Bill24
Joined: 30 Jun 2012 Posts: 45
|
|
Posted: Tue Nov 27, 2012 10:51 am |
|
|
Here is some code I have got working on a PICDEM PIC18 board with a PIC 18F87K22.
I recommend always start prototyping code with WORKING hardware that use the same device as you intend to use in your own design.
I have left some lines of code commented out to show things I have tried but found to be not needed.
Hope this helps.
Code: | #include <18F87K22.h>
#device ICD=TRUE
#device adc=16
#FUSES NOWDT //No Watch Dog Timer
#FUSES WDT128 //Watch Dog Timer uses 1:128 Postscale
#FUSES VREGSLEEP_SW //Ultra low-power regulator is enabled
#FUSES INTRC_LP //LF-INTOSC in Low-Power mode during Sleep
//#FUSES SOSC_DIG //Digital mode, I/O port functionality of RC0 and RC1
#FUSES INTRC_IO //Internal RC Osc, no CLKOUT
#FUSES PUT //Power Up Timer
#FUSES BORM_LOW //Low-power BOR
#FUSES WDT_NOSLEEP //Watch Dog Timer, disabled during SLEEP
#FUSES DEBUG //Debug mode for use with ICD
// RTC to run from the secondary oscillator (RTCOSC_T1 fuse).
#FUSES SOSC_HIGH
#FUSES RTCOSC_T1
#use delay(int=8000000,RESTART_WDT)
#USE FAST_IO(a)
#USE FAST_IO(c)
#USE FAST_IO(c)
#USE FAST_IO(f)
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8,stream=PORT1)
// Borrowed code
unsigned int8 get_number(void)
{
char first,second;
do {
first=getc();
} while ((first<'0') || (first>'9'));
putc(first);
first-='0';
do {
second=getc();
} while (((second<'0') || (second>'9')) && (second!='\r'));
putc(second);
if(second=='\r')
return(first);
else
return((first*10)+(second-'0'));
}
// Borrowed code
void set_clock(rtc_time_t &date_time)
{
printf("\r\nPress ENTER after 1 digit answers.");
printf("\r\nYear 20: ");
date_time.tm_year=get_number();
printf("\r\nMonth: ");
date_time.tm_mon=get_number();
printf("\r\nDay: ");
date_time.tm_mday=get_number();
printf("\r\nWeekday 1-7: ");
date_time.tm_wday=get_number();
printf("\r\nHour: ");
date_time.tm_hour=get_number();
printf("\r\nMin: ");
date_time.tm_min=get_number();
date_time.tm_sec=0;
printf("\r\n\n");
}
void main(void)
{
int tmpcnt = 0;
unsigned int32 tmpcnt2 = 0;
// Set PIN_A2 ( LCD SPI chip sel) to output.
set_tris_a(0x0FB);
// Set Pin_C3 (clk ) and pin_C5 (si) to output.
// set_tris_c(0x0D7);
// Also set C6 as out put for RS232 TX
set_tris_c( 0b10010111);
// Set PIN_D0 to output for test LEDs.
set_tris_d(0x0FE);
// Set Pin_F6 (LCD SPI reset ) to output.
set_tris_f(0x0BF);
setup_rtc(RTC_ENABLE,0); //enables internal RTCC
//setup_oscillator(OSC_SOSC_ON);
//setup_rtc(RTC_ENABLE| RTC_OUTPUT_SECONDS,0); //enables internal RTCC
rtc_time_t write_clock, read_clock;
set_clock(write_clock);
rtc_write(&write_clock); //writes new clock setting to RTCC
//Test - blinking LED program
while(true)
{
tmpcnt2++;
rtc_read(&read_clock); //reads clock value from RTCC
printf("\r%02u/%02u/20%02u ",read_clock.tm_mon,read_clock.tm_mday,read_clock.tm_year,);
printf("%02u:%02u:%02u",read_clock.tm_hour,read_clock.tm_min,read_clock.tm_sec);
printf( "\r\n" );
printf("%lu",tmpcnt2);
printf( "\r\n" );
output_low(PIN_D0);
output_high(PIN_D1);
output_low(PIN_D2);
output_high(PIN_D3);
output_low(PIN_D4);
delay_ms(100);
output_high(PIN_D0);
output_low(PIN_D1);
output_high(PIN_D2);
output_low(PIN_D3);
output_high(PIN_D4);
delay_ms(100);
}
} |
|
|
 |
lucasromeiro
Joined: 27 Mar 2010 Posts: 167
|
|
Posted: Tue Nov 27, 2012 2:50 pm |
|
|
Thanks for the help.
I will test the code and notice the results.
Already tried everything and nothing worked.
Very strange!
thank you
Hugs |
|
 |
|