20X2 rplaced with 28X2. hserin stopped working

ferrymanr

Member
I transferred my code from 20X2 to 28X2 and got all the PWM code and math working correctly but am having problems getting my serial comms working again. I am using HSERSETUP B9600_16,%001 to run in background as before but hserptr only shows a couple of characters as being in the buffer when actually I sent eight of them, so it is missing characters. Also I am getting nothing when I do a 'get' as below.
get 0, variable1
get 1, variable2
get 3, variable3
etc.

Is there difference iin the way these chips handle hser in background mode? I tried changing to 1200bd with the same result. Could hpwm be affecting the serial comms? I changed from the 20X2 to 28X2 so I could get two hpwm outputs working and I was not using any pwm on the 20X2.
Richard
 

hippy

Ex-Staff (retired)
There shouldn't be any fundamental differences I can see apart from the 28X2 having a scratchpad size of 1024 bytes against the 20X2's 128.

Neither PWMOUT nor HPWM should affect the background receive but you could always comment those out to see if it improves things. In fact, it's probably a good idea to start with code which just reads background receive without all the clutter of other code to check that is working as expected first.
 

ferrymanr

Member
Found the problem. This 28X2 has different clock criteria and only works to 8MHz on internal resonator. That screwed up the serial baudrate.

Richard
 

srnet

Senior Member
Found the problem. This 28X2 has different clock criteria and only works to 8MHz on internal resonator. That screwed up the serial baudrate.

Richard
Er .... The 28X2 works to 16Mhz on the internal oscillator.

So maybe your problem was something else ?
 

nick12ab

Senior Member
But if you're using the 28X2-5V, that does only go up to 8MHz.

@OP: If your chip is marked PIC18F45K22 then you have a PICAXE-28X2 which will do 16MHz internal and 64MHz external but if you have a chip marked PIC18F4520 then you have an older PICAXE-28X2-5V which will do 8MHz internal and 40MHz external.
 
Last edited:

ferrymanr

Member
Bit of a long delay in replying but have been away (holiday? in hospital).
I did most of my early testing on the old PIC18F2520 with B.1 firmware. I changed to PIC18F25K22 just before I had to suspend developement of my project. At that point I could get two channels of HPWM with common frequency but individual duty cycles. I managed to get HSERIN working but it was very temperamental and seemed to miss characters as HSERPTR was not incrementing correctly. I got the feeling there was interaction betwwen the timer used for HPWM and that used for HSERIN.
Now I have to try and get my mindset back to where I was a couple of weeks ago.
 
Top