|
|
View previous topic :: View next topic |
Author |
Message |
Linuxbuilders
Joined: 20 Mar 2010 Posts: 193 Location: Auckland NZ
|
18f45j11 b3 not working |
Posted: Tue Dec 14, 2010 7:12 am |
|
|
hi there,
never ending story with 45j11 - 4.114 is killing whole chip...I wish they fix it one day...goes mad after it, so I use 4.107 as it was reasonable stable before.
what is happening
PIN B3 is switching from OUT to IN when I change tris and I can measure it on my multimeter on the chip and in the circuit, all other pins works correctly as inputs and outputs but not B3...
it always reads 0 and no reaction if I apply 1 (3.25) or not...
this is my program...
Code: |
//=========DEFINE====================
#define Rx_In PIN_C7 // serial bus data receive pin
#define Tx_Out PIN_C6 // serial bus data transmit pin
#define Tx_On PIN_B1 // serial bus TX on
#define Heartbit_On PIN_B0 // led
#define CTS PIN_C0
#define DTR PIN_C1 // DATA TX READY
#define add1 PIN_D0
#define add2 PIN_D1
#define add4 PIN_D2
#define add8 PIN_D3
#define add16 PIN_D4
#define add32 PIN_D5
#define add64 PIN_D6
#define add128 PIN_D7
#define server_on_led PIN_B2 // server on LED
#define bus_link PIN_B3 // bus link
#define server_link PIN_B4 // server link
#define relay PIN_A5 // relay output
//===================================
//===================================
#FUSES WDT //No Watch Dog Timer
#FUSES WDT2048 //Watch Dog Timer uses 1:128 Postscale
#FUSES HS
#FUSES NODEBUG //No Debug mode for ICD
#FUSES NOXINST //Extended set extension and Indexed Addressing mode disabled (Legacy mode)
#FUSES STVREN //Stack full/underflow will cause reset
#FUSES NOPROTECT //Code not protected from reading
#FUSES FCMEN //Fail-safe clock monitor enabled
#FUSES NOIESO //Internal External Switch Over mode disabled
//#FUSES IOL1WAY //Allows only one reconfiguration of peripheral pins
#FUSES NOWPCFG
#FUSES WPEND
#FUSES WPDIS
#FUSES NOLPT1OSC //Timer1 configured for higher power operation
#FUSES NOT1DIG
#FUSES MSSPMSK7
#FUSES DSWDT2048
#FUSES NODSWDT
#FUSES NODSBOR
#FUSES RTCOSC_INT
#FUSES DSWDTOSC_INT
#FUSES WPFP
#use delay (clock=20000000)
#pin_select U2TX = PIN_C5
#pin_select U2RX = PIN_C4
#use rs232(uart1,baud=19200,xmit=Tx_Out,rcv=Rx_In,parity=N,bits=8,stop=1,stream=bus,restart_wdt,errors,TIMEOUT=5)
#use rs232(uart2,baud=19200,parity=N,bits=8,stop=1,stream=eth,restart_wdt,errors,TIMEOUT=5)
#use fast_io(A)
#use fast_io(B)
#use fast_io(C)
#use fast_io(D)
#use fast_io(E)
//===================================
.
.
.
.
setup_wdt(WDT_ON); //set watch dog timer
disable_interrupts(GLOBAL); //clear interrupts
port_b_pullups(false);
delay_us(10);
set_timer0(0); //clear timers
set_rtcc(0); //clear timers
setup_timer_0(RTCC_INTERNAL | RTCC_8_BIT | T0_DIV_1); //set timer 0 parameters
setup_adc_ports(ALL_ANALOG | sAN0 | VSS_VDD); //set AD ports
setup_adc(ADC_CLOCK_INTERNAL | ADC_CLOCK_DIV_8);
setup_spi(SPI_SS_DISABLED);
setup_spi2(SPI_SS_DISABLED);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_timer_3(T3_DISABLED|T3_DIV_BY_1);
setup_timer_4(T4_DISABLED,0,1);
setup_ccp1(CCP_OFF);
setup_ccp2(CCP_OFF);
setup_comparator(NC_NC_NC_NC); //turn off comparators
enable_interrupts(GLOBAL); //clear interrupts
enable_interrupts(INT_RTCC);
enable_interrupts(INT_RDA);
enable_interrupts(INT_RDA2);
set_tris_a(0xDF); // (1,1,0,1,1,1,1,1);
set_tris_b(0xF8); // (1,1,1,1,1,0,0,0);
set_tris_c(0xFD); // (1,0,0,1,1,1,0,1);
set_tris_d(0xFF); // (1,1,1,1,1,1,1,1);
set_tris_e(0xFF); // (1,1,1,1,1,1,1,1);
//setup flags///////////////////
.
.
.
.
if (bus_on == 0) {
outputLow(server_on_led);
//outputHigh(relay);
}
else {
outputHigh(server_on_led);
//outputLow(relay);
}
|
any ideas? fault in device.h file? - how to check it?...
thnx _________________ Help "d" others and then you shell receive some help from "d" others. |
|
|
Linuxbuilders
Joined: 20 Mar 2010 Posts: 193 Location: Auckland NZ
|
|
Posted: Tue Dec 14, 2010 7:16 am |
|
|
another story is that after installation of 4.114 on W7 when I try to compile I get I/O error 103. any ideas what it means? MPLAB 8.60 thnx _________________ Help "d" others and then you shell receive some help from "d" others. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Dec 14, 2010 1:19 pm |
|
|
Post a small, complete, compilable test program. You didn't want to do
that in your last thread, so you never got the problem to be looked closely
by any of us.
Your code in this thread is not complete. It contains a lot of code that
is not needed to show the problem (at least 90% can be cut), and it
doesn't compile. |
|
|
Linuxbuilders
Joined: 20 Mar 2010 Posts: 193 Location: Auckland NZ
|
|
Posted: Tue Dec 14, 2010 2:37 pm |
|
|
Hi, thnx for help...
Hard to paste a program when it is 11K. And "small working program" you have got already with all required details there. I think there is not really required whole program structure just to see where the problem is... use your imagination. There is really nothing else required in this case.
Thnx guys. _________________ Help "d" others and then you shell receive some help from "d" others. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Dec 14, 2010 2:42 pm |
|
|
I can't really work on it then. Maybe someone else can help. |
|
|
Linuxbuilders
Joined: 20 Mar 2010 Posts: 193 Location: Auckland NZ
|
|
Posted: Wed Dec 15, 2010 1:47 am |
|
|
What do you need? If I post working program then it will be incomplete and not doing any good anyway, and then if it will be working then what is the point of putting it in. The problem is not a program, B3 does not register change on input. I was thinking that it is a pull ups problem but it does not look like that. I am thinking more about ccs definitions for this chip, in 107 there was few problems like H4 not working, fuses, etc. When I know that there are issues within PICC and the same problem does not exist on other inputs in this program with use of the same methods then what else can it be?
...and part of the problem discovered...
fresh installation of 4.114 on my laptop works, upgrade over 4.107 with 4.114 kills whole compiler, does rubbish and makes whole thing malfunction. Win7 Pro 32bit. Even if I kill whole thing on HDD and remove regs then still have a crap there somewhere. This is bad. Anyone knows where files are kept apart of PICC and USER->Remote... ? Any special regs which needs to be removed? Or Win re-installation required? B3 still does not work...will get there too... Thnx
next question:
What should be correct setting of TRIS for RS232 TX PIN? RX I set as input, should I set TX as output or as input? I would prefer to use #USE FIXED_IO - there is no good description available, I see people asking abut it but there is no clear answer so I ask again more precisely.
#use fixed_io(a_outputs=PIN_A2, PIN_A3)
Is is correct if PIN_A2 is an input and PIN_A3 is an output. Does is only apply to outputs? Now how is it working in #FUSES IOL1WAY?
I have noticed that if I define my all pins in this function and I use this fuse than on 18f4520 everything works nut on 18f45j11 does not and it is a gamble. So I use TRIS on this chip. I suspect that all pins defined inside this function are treated as an input or output and when I do first operation on the pin then #FUSES IOL1WAY lock them out into only one direction. Am I right? Could someone clarify this subject please. Thnx
Thnx _________________ Help "d" others and then you shell receive some help from "d" others. |
|
|
Linuxbuilders
Joined: 20 Mar 2010 Posts: 193 Location: Auckland NZ
|
|
Posted: Thu Dec 16, 2010 12:43 am |
|
|
Guys, I tell you what I think about this forum. This forum is full of ..., as I come here I find no help whatsoever, sometimes in the past there was few guys here who had a desire and knowledge to help. Now there are Trolls here who can only say "post working code" or "I can't help". If you would read my code which I have pasted you would find there very simple fault. No full working code required, just a bit of focus and desire to help. I do not tell you what is the problem with B3, but it is so visible in pasted code that you must be blind to do not see it. Problems with CCS are still there but can be fixed with device editor but I think it is a bit high level for this forum to get sorted out. I have got help here once. A real answer to real question. Everything else is just rubbish talk about nothing. Better just do not post anything if you have to post little talk. _________________ Help "d" others and then you shell receive some help from "d" others. |
|
|
Wayne_
Joined: 10 Oct 2007 Posts: 681
|
|
Posted: Thu Dec 16, 2010 3:02 am |
|
|
If you know what the fault is why are you posting unless to tell someone about it ?
How did you debug the code to find the fault ? Did YOU just look at these snippets of code and sudenly realise what the problem was or did you change things, re-compile, debug, until it worked ?
You come on here and ask us to spend our precious time to look at a disjointed bit of code that you post for you to turn around and say you fixed it by re-installing the compiler. You have then come back to say that there is a simple bug in the stuff you posted that anyone should be able to see. Does this mean you didn't fix it with a re-install ?
Alot of people new to C make simple mistakes, especially when they start to write large complicated code, even long term coders such as myself and many others on here can make simple errors, we generally fix them ourselves though. By asking them to post a small compilable (not working) piece of code makes it easier for us to help them. It may also help them find the fault themselves.
No one on here, including you wants to take a disjointed bit of code like this, re-write it so that they can compile it and test it on their own time to fix YOUR problem. And with an attitude like yours you shouldn't expect any help soon.
And if the fault is because you are reading
bus_on
when B3 is defined as
#define bus_link PIN_B3 // bus link
Then cutting down this code to a small compilable version whilst keeping the same names would of indeed showed you the error. |
|
|
|
|
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
|