|
|
View previous topic :: View next topic |
Author |
Message |
jruibarroso
Joined: 07 Jan 2006 Posts: 64 Location: Braga
|
Need some CCS code to decode DCF77 receiver |
Posted: Thu Oct 05, 2006 9:28 am |
|
|
Need some CCS code to decode DCF77 receiver
#device<All_Members>
#include<Thank_you> |
|
|
guest Guest
|
|
Posted: Thu Oct 05, 2006 12:27 pm |
|
|
Forget the code, I need enough money so that I don't have to write software. Somehow I don't think we're going to get either so we'd better at least try and achieve aour aims ourselves! |
|
|
The Puma
Joined: 23 Apr 2004 Posts: 227 Location: The Netherlands
|
|
Posted: Mon Sep 24, 2007 7:20 am |
|
|
Has someone a working code for it? |
|
|
inservi
Joined: 13 May 2007 Posts: 128
|
|
Posted: Mon Sep 24, 2007 9:00 am |
|
|
freed space ! _________________ in médio virtus
Last edited by inservi on Sun Sep 30, 2007 9:20 am; edited 1 time in total |
|
|
The Puma
Joined: 23 Apr 2004 Posts: 227 Location: The Netherlands
|
|
Posted: Sun Sep 30, 2007 8:56 am |
|
|
The sample code did't work for me?
Has someone a working code for testing? |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Sep 30, 2007 2:11 pm |
|
|
Try using Google. Here's a complete DCF77 project with a photo of the
output on an LCD, and a schematic, and links to CCS source code.
AND, it's in German, which is your native language.
http://www.fernando-heitor.de/component/option,com_smf/Itemid,121/topic,2899.msg15101
[spam], would you please learn how to use Google ? Don't ask for
source code on this forum until you have done a search with google
for at least one hour. |
|
|
The Puma
Joined: 23 Apr 2004 Posts: 227 Location: The Netherlands
|
|
Posted: Sun Sep 30, 2007 2:53 pm |
|
|
@PCM programmer,
Im Dutch no german, and yes i have use google
and find already the site your sad, but it will not works
The source is for the PIC16F690,
What must i change for use with the PIC18F4620?
PCM help me to make that code to work
this give an error
setup_wdt(WDT_1152MS); // Watchdog für die Initialisierung
port_a_pullups(0b00111111); // pullups Widerstände ein
Code: | ////////////////////////////////////////////////////////////////// WDT
// Watch Dog Timer Functions: SETUP_WDT() or SETUP_COUNTERS() (see above)
// RESTART_WDT()
// WDT base is 18ms
//
#define WDT_18MS 0x8008
#define WDT_36MS 9
#define WDT_72MS 10
#define WDT_144MS 11
#define WDT_288MS 12
#define WDT_576MS 13
#define WDT_1152MS 14
#define WDT_2304MS 15
|
This has not the 18f4620 |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Sep 30, 2007 4:26 pm |
|
|
Comment out the following lines.
Quote: | //#IF getenv("VERSION")>4.018
// #ERROR Compiler Version zu neu, Checksumme OK?
// #ENDIF |
Change the #fuses and the #use rs232() statements as shown below.
Note that the Watchdog Timer is disabled.
Quote: | #include <18F4620.H>
#fuses XT, NOWDT, BROWNOUT, PUT, NOLVP
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS) |
// Use this LCD driver (if you have a 4x20 LCD). It's in the code library.
Quote: | #include <Flex_LCD420.c>
#include "DCF77.h"
|
// Add this statement.
Quote: | #define lcd_putchar(x) lcd_putc(x) |
Comment out the #ROM statements.
Quote: |
// #rom 0x21D0={86,49,46,48,52,48,46,46,46,46,46,46,46,46,46,46}
// #rom 0x21E0={67,67,83,45,52,46,48,49,56,46,46,68,67,70,55,55}
// #rom 0x21F0={49,49,46,48,49,46,50,48,48,55,46,66,70,76,46,46} |
Comment out these lines.
Quote: | // setup_wdt(WDT_OFF);
// restart_wdt();
// port_a_pullups(0b00111111); // pullups Widerstÿÿÿände ein
// set_tris_a(0b00000100); // 0=Output 1=Input
// set_tris_b(0b00000000); // 0=Output 1=Input
// set_tris_c(0b00000000); // 0=Output 1=Input
|
There might be a few other changes that I forgot to post, but that's most
of them.
Also, the DCF77 signal must be connected to pin B0, because his code
uses the INT0 pin (RB0) to receive it. He uses the #INT_EXT interrupt
to detect the edges of the DCF77 signal. The schematic shows the
DCF77 device has a 4.7K pullup on it. |
|
|
The Puma
Joined: 23 Apr 2004 Posts: 227 Location: The Netherlands
|
|
Posted: Mon Oct 01, 2007 7:43 am |
|
|
These things must also changed for the 18f4620
Code: | /****************************************************************************************
* ---- Name der Internal Register und ihre direkten Adressen ------------- *
****************************************************************************************/
#byte IND = 0x000 ----> 18f4620 ???
#byte TMR0 = 0x001 ----> 18f4620 (TMR0L & H)
#byte PCL = 0x002 ----> 18f4620 (ff9h)
#byte STATUS = 0x003 ----> 18f4620 (fd8h)
#byte FSR = 0x004 ----> 18f4620 (???)
#byte PORTA = 0x005 ---> 18f4620 (f80h)
#byte PORTB = 0x006 ----> 18f4620( f81h)
#byte PORTC = 0x007---- > 18f4620 (f82h)
#byte TMR1L = 0x00E ---> 18f4620 (fceh)
#byte TMR1H = 0x00F ---> 18f4620 (fcfh)
#byte T1CON = 0x010 ---> 18f4620 (fcdh)
/ |
|
|
|
The Puma
Joined: 23 Apr 2004 Posts: 227 Location: The Netherlands
|
|
Posted: Mon Oct 01, 2007 9:11 am |
|
|
It did't work for me |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Oct 01, 2007 10:55 am |
|
|
The only register in that list that he uses in his code is TMR1H.
Comment out all the other #byte statements. |
|
|
The Puma
Joined: 23 Apr 2004 Posts: 227 Location: The Netherlands
|
|
Posted: Mon Oct 01, 2007 1:28 pm |
|
|
So far i change the code, but no luck, it is not running
I get only this on the LCD
Signal char --:--:00
That's all
Hope someone can help further
Code: | #include <18F4620.h>
#use delay(clock=20000000)
#fuses HS,NOWDT,NOBROWNOUT,NOPUT,NOLVP,DEBUG,NOSTVREN,NOPROTECT
#include <flex_lcd420.h>
#include <dcf77.h>
#define dcf77_sensor PIN_B0 // RB0 Eingang DCF77 Signal Conrad Modul Nr.641138
#define anzeige PIN_C0
#byte TMR1L=0xFCE
#byte TMR1H=0xFCF
unsigned char x;
unsigned char sek_zahler,dcf_bit,dcf77_start_bit;
unsigned char timer1_H,timer1_L,timer1_uberlauf;
unsigned char min,std;
unsigned char wochentag,day,month,year;
unsigned char parity;
unsigned char merk_bit1;
#bit flanke =merk_bit1.0
#bit impuls_ok =merk_bit1.1
#bit lcd_aktualisieren=merk_bit1.2
#bit lcd_parity =merk_bit1.3
#int_TIMER1
void uberlauf_timer1(void) {
timer1_uberlauf++;
}
#int_ext
void interrupt(void) {
if(flanke) {
setup_timer_1(T1_DISABLED);
dcf77_start_bit=timer1_uberlauf;
timer1_uberlauf=0;
timer1_H=TMR1H;
timer1_L=TMR1L;
impuls_ok=1;
restart_wdt();
ext_int_edge(L_TO_H);
setup_timer_1(T1_INTERNAL|T1_DIV_BY_4);
flanke=0;
}
else {
set_timer1(0);
ext_int_edge(H_TO_L);
flanke=1;
}
}
byte dez_bcd(byte value) {
return(((value/10)*16)+(value%10));
}
void lcd_ausgabe(void) {
lcd_gotoxy(2,1);
if(lcd_parity) {
if(sek_zahler%2)
lcd_putchar(1);
else
lcd_putchar(2);
}
else {
if(sek_zahler%2)
lcd_putchar(3);
else
lcd_putchar(5);
}
lcd_gotoxy(10,1);
printf(lcd_putc,"%02u",sek_zahler);
// if((!sek_zahler)&&(parity==3))
// printf("\n\r %02u.%02u.20%02u %02u:%02u",day,month,year,std,min);
if(!sek_zahler) {
if(parity==3) {
lcd_gotoxy(1,2); ausgabe_LCD_wochentag(wochentag); printf(lcd_putc," %02u.%02u.20%02u",day,month,year);
wochentag=0; day=0; month=0; year=0;
lcd_gotoxy(3,1); printf(lcd_putc," %02u:%02u:",std,min);
min=0; std=0;
lcd_parity=1;
}
else {
lcd_parity=0;
lcd_gotoxy(3,1); printf(lcd_putc," --:--:");
}
parity=0;
}
}
void dcf77_Uhr(void) {
if(impuls_ok) {
impuls_ok=0;
sek_zahler=dcf77_daten(dcf77_start_bit,sek_zahler);
lcd_ausgabe();
dcf_bit=dcf77_timer1(timer1_H);
min =dcf77_min(sek_zahler,dcf_bit,min);
std =dcf77_std(sek_zahler,dcf_bit,std);
day =dcf77_day(sek_zahler,dcf_bit,day);
wochentag=dcf77_wochentag(sek_zahler,dcf_bit,wochentag);
month =dcf77_month(sek_zahler,dcf_bit,month);
year =dcf77_year(sek_zahler,dcf_bit,year);
if(sek_zahler%2)
output_high(anzeige);
else
output_low(anzeige);
if(sek_zahler==28)
parity=parity_check_1(dez_bcd(min),dcf_bit);
if(sek_zahler==35)
parity+=parity_check_1(dez_bcd(std),dcf_bit);
if(sek_zahler==58) {
x=100;
while(x) {
delay_ms(10);
x--;
restart_wdt();
}
x=dez_bcd(day)^dez_bcd(wochentag)^dez_bcd(month)^dez_bcd(year);
parity+=parity_check_1(x,dcf_bit);
impuls_ok=1;
}
}
}
void initialisierung(void) {
// setup_wdt(WDT_1152MS);
// restart_wdt();
// port_a_pullups(0b00111111);
// set_tris_a(0b00000100);
// set_tris_b(0b00000000);
// set_tris_c(0b00000000);
// PORTA=0; PORTB=0;
setup_comparator(NC_NC_NC_NC);
disable_interrupts(GLOBAL);
disable_interrupts(INT_TIMER1);
setup_timer_1(T1_INTERNAL|T1_DIV_BY_4);
timer1_H=0;
timer1_L=0;
sek_zahler=0;
dcf77_start_bit=0;
timer1_uberlauf=0;
min=0; std=0; wochentag=0;
day=0; month=0; year=0;
impuls_ok=1;
parity=0;
lcd_parity=0;
lcd_aktualisieren=1;
lcd_init();
lcd_init_custom_chars();
restart_wdt();
printf(lcd_putc,"\f");
ext_int_edge(L_TO_H);
enable_interrupts(INT_EXT);
enable_interrupts(INT_TIMER1);
enable_interrupts(GLOBAL);
}
void main() {
switch(RESTART_CAUSE()) {
case WDT_FROM_SLEEP:
break;
case WDT_TIMEOUT:
initialisierung();
break;
case NORMAL_POWER_UP:
initialisierung();
break;
default:
initialisierung();
break;
}
while(TRUE) {
restart_wdt();
dcf77_Uhr();
}
} |
|
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Oct 01, 2007 1:40 pm |
|
|
His code runs at 4 MHz, and he is using Div by 4, for the Timer1 clock.
Code: | #use delay(clock=4000000)
setup_timer_1(T1_INTERNAL|T1_DIV_BY_4); |
The timer is clocked at the instruction rate, which is 4 MHz/ 4 = 1 MHz.
Then the Div by 4 reduces that to 1 MHz/4 = 250 KHz.
You changed the oscillator frequency to 20 MHz. You still have the
the same Div by 4 value. But, there is no divisor available that is
large enough to reduce the Timer1 clock down to 250 KHz with a
20 MHz crystal.
My advice is to change your board to use a 4 MHz crystal. |
|
|
The Puma
Joined: 23 Apr 2004 Posts: 227 Location: The Netherlands
|
|
Posted: Mon Oct 01, 2007 1:57 pm |
|
|
It must be possible to use the dcf77 module with a 20Mhz frq. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Oct 01, 2007 2:15 pm |
|
|
I'm sure it is, but that code is setup for one particular method.
I think you should install a 4 MHz crystal and see if it works.
Then at least you will have some DCF77 code working. |
|
|
|
|
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
|