PDA

View Full Version : some days I hate pic's (serout,gsm,usb,f88)



f_lez
- 19th August 2006, 15:03
Yesterday I wrote a simple program


Loop:

high porta.0
pause 500
low porta.0
pause 500
high porta.0
pause 500
low porta.0
pause1000

serout porta.1, N9600,["AT",13,10]

goto loop.


simple, flash led and send AT down a 1k resistor to my serial port.

Worked a treat. left hyperterminal running and showing AT for hours...


Got an old phone datacable, hacked into the wires, its only a max232 in a moulded plug, connect it to the pic, looked at monitor, nothing on screen, occasional garbage......

How can this be? the simple and dirty resistor trick works, the 'proper' way with a level shifter isnt working?

Ha! I should use T9600.............

Nothing.....

OT9600, nothing.

Back to the simple resistor, all is fine, so I have not upset the pic.....

9600 on a 4mhz, emm, I'll drop to 4800, oh hang on compiler error, better make that 2400..........


Maybe I have killed the old phone data cable?

get another one! this ones not a max 232 but a pl203 usb one, nothing......

Reconnect them up and test them on the phone, thats ok.

connect the two datacables together! put one on com 1 and the other on 5, oh look what I type in one window appears in the other!

Connect both to the pic, nothing.............garbage............

At this point I was going to go sit in the garden and break out a beer.

I decided it must be voltage levels, so started to play with a 1k resistor between pin Ra1 and gnd and 5v, no real improvement, very odd...

I remember something about port A pullups and problems, so I changed to code to serout on portb.6.........

That was it, all problems fixed.......

At this point I dont care anymore, I'll just never use port A again!

Odd that even on portb, using no pullups or anything both OT2400 and T2400 appear on both the max232 and the pl2303

Best news is I have connect the pic to my phone, and one of the cables, and can see the phone echoing back whats sent, so I'll soon have my house/car alarm....

mister_e
- 19th August 2006, 19:13
At this point I dont care anymore, I'll just never use port A again!

i have no problem with that... if i disable analog stuff before. On PORTA... there's big chance.

Wich PIC?

f_lez
- 20th August 2006, 08:23
i have no problem with that... if i disable analog stuff before. On PORTA... there's big chance.

Wich PIC?


The good ol' F88.

I want to write the code on the 2550, but it wont fit in my programmer and I have not yet made a header, or the pcb for my project, if I had, I could have used ISP on the 2550.....

So I just grabbed a F88 off my serial relay project and erased it, started on that one.

I cant see why if the Pic running at 5v can drain enough current through port A to make the PC serial port see data, why it cant make a max 232 see data when its pumping 5v into a 5v input..............

Other odd thing is all my port a's and port b's have 1k resistors and leds on, that way I can 'see' when data is being thrown out, on port B the led is brighter than on port A.......

Setting the port pins high with the 'high portx.y' cause the leds to be the same brightness, on either port a or b.

If there the same brightness, it cant be the pic's port is not sourcing as much current, they the same, but with a serout command they are not the same brightness, so whats going on!

either its a pic chip thing, or a compiler thing setting something different, or not setting something 'extra' that port A needs to source as much current in serout mode as port B does.

I would like to know whats going on, as both should work and only one is, but I'm not letting it slow me down I can live with only using port B for now while I test the code snippets, and I was using port B on the final board design anyway, was just annoyed at losing nearly a day to find a solution thats a problem caused by an 'undocumented feature'

Now I need to find a way to store 150 bytes of 9600 baud incoming data and pics have no strings IIRC

Its no doubt in a manual somewhere.................

mister_e
- 20th August 2006, 09:02
Ok so at least you never opened the PIC16F88 datasheet and discover what's multiplexed on PORTA and if it's enable by default? Right?

Once done, you'll know why.

f_lez
- 20th August 2006, 22:21
Ok so at least you never opened the PIC16F88 datasheet and discover what's multiplexed on PORTA and if it's enable by default? Right?

Once done, you'll know why.

I read the picbasic manual instead, it said if thou use that pin for serial, it shalt do serial.

Which it does, but just not as efficiently, and only to some devices...........


If I set the port pin high with a high command, I get the same voltage on the pin as any other I set high, I dont have to worry about whats multiplexed on it / other uses it has, so why should the serout command not set everything up also?

In the manual little notes are included about other pic's with ''odd'' behaviour so I just presumed this had none to worry about.

mister_e
- 20th August 2006, 23:09
it's not odd or curious.. it's normal. You're working with digital signal on analog by default I/o.

Open the PIC16F88 datasheet and discover the Analog section... section 12.0 and 13.0.

Now you need to disable the analog stuff
section 12.0 register 12-1 ANSEL:
ANSEL=0 ' set all related i/o to digital mode

Section 13.0 register 13-1 CMCON (and figure 13-1)
CMCON=7 ' Disable analog comparator

ok those comparator are already disabled by add the line just for safety sake

So add
ANSEL=0
CMCON=7
at the top of your code.
About now?